Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

test_uuidset.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import subprocess
  2. import tempfile
  3. import unittest
  4. from dataladmetadatamodel.datasettree import DatasetTree
  5. from dataladmetadatamodel.metadatapath import MetadataPath
  6. from dataladmetadatamodel.uuidset import (
  7. UUIDSet,
  8. VersionList,
  9. )
  10. from dataladmetadatamodel.versionlist import VersionRecord
  11. from .utils import (
  12. assert_uuid_sets_equal,
  13. create_dataset_tree,
  14. get_uuid
  15. )
  16. uuid_0 = get_uuid(0)
  17. uuid_1 = get_uuid(1)
  18. uuid_2 = get_uuid(2)
  19. class TestUUIDSet(unittest.TestCase):
  20. def test_basic(self):
  21. UUIDSet()
  22. def test_copy_from_memory(self):
  23. with \
  24. tempfile.TemporaryDirectory() as original_dir, \
  25. tempfile.TemporaryDirectory() as copy_dir:
  26. subprocess.run(["git", "init", original_dir])
  27. subprocess.run(["git", "init", copy_dir])
  28. uuid_set = UUIDSet(initial_set={
  29. uuid_0: VersionList(initial_set={
  30. "v0": VersionRecord(
  31. "1.2",
  32. MetadataPath("path0"),
  33. create_dataset_tree()
  34. )
  35. }),
  36. uuid_1: VersionList(initial_set={
  37. "v0.0": VersionRecord(
  38. "1.3",
  39. MetadataPath("path0.0"),
  40. create_dataset_tree()
  41. )
  42. })
  43. })
  44. copied_uuid_set = uuid_set.deepcopy(new_destination=copy_dir)
  45. copied_uuid_set.read_in()
  46. assert_uuid_sets_equal(self, uuid_set, copied_uuid_set)
  47. def test_copy_from_backend(self):
  48. with \
  49. tempfile.TemporaryDirectory() as original_dir, \
  50. tempfile.TemporaryDirectory() as copy_dir:
  51. subprocess.run(["git", "init", original_dir])
  52. subprocess.run(["git", "init", copy_dir])
  53. uuid_set = UUIDSet(initial_set={
  54. uuid_0: VersionList(initial_set={
  55. "v0": VersionRecord(
  56. "1.2",
  57. MetadataPath("path0"),
  58. create_dataset_tree()
  59. )
  60. }),
  61. uuid_1: VersionList(initial_set={
  62. "v0.0": VersionRecord(
  63. "1.3",
  64. MetadataPath("path0.0"),
  65. create_dataset_tree()
  66. )
  67. })
  68. })
  69. uuid_set.write_out(original_dir)
  70. uuid_set_copy = uuid_set.deepcopy(new_destination=copy_dir)
  71. # assert that the purged uuid-sets are equal
  72. uuid_set.purge()
  73. assert_uuid_sets_equal(self, uuid_set, uuid_set_copy)
  74. # load both and compare the uuid set level
  75. uuid_set.read_in()
  76. uuid_set_copy.read_in()
  77. assert_uuid_sets_equal(self, uuid_set, uuid_set_copy)
  78. if __name__ == '__main__':
  79. unittest.main()