test_uuidsetmapper.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import unittest
  2. from unittest import mock
  3. from uuid import UUID
  4. location_0 = "a000000000000000000000000000000000000000"
  5. location_1 = "a000000000000000000000000000000000000001"
  6. uuid_0 = UUID("00000000000000000000000000000000")
  7. uuid_1 = UUID("00000000000000000000000000000001")
  8. expected_tree_args = {
  9. ('100644', 'blob', 'a000000000000000000000000000000000000001', '00000000-0000-0000-0000-000000000001'),
  10. ('100644', 'blob', 'a000000000000000000000000000000000000001', '00000000-0000-0000-0000-000000000000')
  11. }
  12. class TestUUIDSetMapper(unittest.TestCase):
  13. def test_basic_unmapping(self):
  14. from dataladmetadatamodel.uuidset import UUIDSet
  15. from dataladmetadatamodel.versionlist import VersionList
  16. with mock.patch("dataladmetadatamodel.mapper.gitmapper.uuidsetmapper.git_save_tree") as save_tree, \
  17. mock.patch("dataladmetadatamodel.mapper.gitmapper.uuidsetmapper.git_update_ref") as update_ref, \
  18. mock.patch("dataladmetadatamodel.mapper.gitmapper.versionlistmapper.git_save_json") as save_json:
  19. save_tree.configure_mock(return_value=location_0)
  20. save_json.configure_mock(return_value=location_1)
  21. uuid_set = UUIDSet({
  22. uuid_0: VersionList(),
  23. uuid_1: VersionList()
  24. })
  25. uuid_set.write_out("/tmp/t1")
  26. tree_args = save_tree.call_args[0][1]
  27. self.assertEqual(tree_args, expected_tree_args)
  28. if __name__ == '__main__':
  29. unittest.main()