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_metadatapath.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import unittest
  2. from unittest.mock import patch
  3. from pathlib import (
  4. PurePosixPath,
  5. PureWindowsPath
  6. )
  7. from dataladmetadatamodel.metadatapath import MetadataPath
  8. class TestMetadataPath(unittest.TestCase):
  9. def test_empty_join(self):
  10. self.assertEqual(
  11. MetadataPath("") / MetadataPath(""),
  12. MetadataPath(""))
  13. def test_empty_leading(self):
  14. self.assertEqual(
  15. MetadataPath("") / MetadataPath("") / MetadataPath("a"),
  16. MetadataPath("a"))
  17. def test_common(self):
  18. self.assertEqual(
  19. MetadataPath("") / MetadataPath("") / MetadataPath(
  20. "a") / MetadataPath("b"),
  21. MetadataPath("a/b"))
  22. def test_multiple_dashes(self):
  23. self.assertEqual(
  24. MetadataPath("/") / MetadataPath("a//") / MetadataPath("b"),
  25. MetadataPath("a/b"))
  26. def test_intermediate_root(self):
  27. self.assertEqual(
  28. MetadataPath("/") / MetadataPath("a//") / MetadataPath("/b"),
  29. MetadataPath("a/b"))
  30. def test_windows_paths(self):
  31. # Enforce windows path interpretation
  32. with patch("dataladmetadatamodel.metadatapath.PurePosixPath", new=PureWindowsPath):
  33. metadata_path = MetadataPath("a\\b\\c")
  34. self.assertEqual(metadata_path, MetadataPath("a/b/c"))
  35. with patch("dataladmetadatamodel.metadatapath.PurePosixPath", new=PureWindowsPath):
  36. metadata_path = MetadataPath("a/b/c")
  37. self.assertEqual(metadata_path, MetadataPath("a/b/c"))
  38. def test_posix_paths(self):
  39. with patch("dataladmetadatamodel.metadatapath.PurePosixPath", new=PurePosixPath):
  40. metadata_path = MetadataPath("a/b/c")
  41. self.assertEqual(metadata_path, MetadataPath("a/b/c"))
  42. if __name__ == '__main__':
  43. unittest.main()