test_sync.py 1018 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import re
  3. import unittest.mock
  4. from symuid import Track
  5. from symuid.sync import _main, sync
  6. DUMMY_PATH_IGNORE_REGEX = re.compile(r'\.jpg$')
  7. def test_sync(empty_ogg_opus_path):
  8. assert Track(empty_ogg_opus_path).get_uuid() is None
  9. sync(os.path.dirname(empty_ogg_opus_path),
  10. path_ignore_regex=DUMMY_PATH_IGNORE_REGEX)
  11. assert Track(empty_ogg_opus_path).get_uuid() is not None
  12. def test_sync_idempotent(empty_ogg_opus_path):
  13. sync(os.path.dirname(empty_ogg_opus_path),
  14. path_ignore_regex=DUMMY_PATH_IGNORE_REGEX)
  15. uuid = Track(empty_ogg_opus_path).get_uuid()
  16. sync(os.path.dirname(empty_ogg_opus_path),
  17. path_ignore_regex=DUMMY_PATH_IGNORE_REGEX)
  18. assert Track(empty_ogg_opus_path).get_uuid() == uuid
  19. def test_main(empty_ogg_opus_path):
  20. assert Track(empty_ogg_opus_path).get_uuid() is None
  21. with unittest.mock.patch('sys.argv', ['', os.path.dirname(empty_ogg_opus_path)]):
  22. _main()
  23. assert Track(empty_ogg_opus_path).get_uuid() is not None