test_settings.py 885 B

123456789101112131415161718192021222324252627282930313233343536
  1. import tempfile
  2. import unittest
  3. from video2midi.prefs import prefs
  4. from video2midi.settings import *
  5. class TestMySettings(unittest.TestCase):
  6. def test_a_settings_load(self) -> None:
  7. self.assertEqual(prefs.xoffset_whitekeys, 60)
  8. loadsettings('./tests/spin.mp4.ini')
  9. self.assertEqual(prefs.xoffset_whitekeys, 99)
  10. def test_b_persist_octave(self) -> None:
  11. ini = tempfile.NamedTemporaryFile(suffix='.ini').name
  12. prefs.octave = 2
  13. savesettings(ini)
  14. prefs.octave = 3
  15. loadsettings(ini)
  16. self.assertEqual(prefs.octave, 2)
  17. def test_c_compatible_size(self) -> None:
  18. loadsettings('./tests/spin.mp4.ini')
  19. self.assertEqual(len(prefs.keyp_colors_channel_prog),14);
  20. colorBtns = []
  21. for i in range(22):
  22. colorBtns.append( [0,0,0] )
  23. compatibleColors(colorBtns)
  24. self.assertEqual(len(prefs.keyp_colors_channel_prog),22);
  25. if __name__ == '__main__':
  26. unittest.main()