You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

4 years ago
  1. import unittest
  2. from unittest.mock import patch
  3. from tests.harness import instrumentGooey
  4. from gooey import GooeyParser
  5. from gooey.tests import *
  6. class TestGooeySlider(unittest.TestCase):
  7. def makeParser(self, **kwargs):
  8. parser = GooeyParser(description='description')
  9. parser.add_argument('--slider', widget="Slider", **kwargs)
  10. return parser
  11. def testSliderDefault(self):
  12. cases = [
  13. [{}, 0],
  14. [{'default': 0}, 0],
  15. [{'default': 10}, 10],
  16. [{'default': 76}, 76],
  17. # note that WX caps the value
  18. # unless explicitly widened via gooey_options
  19. [{'default': 81234}, 100],
  20. # here we set the max to something higher than
  21. # the default and all works as expected.
  22. # this is a TODO for validation
  23. [{'default': 81234, 'gooey_options': {'max': 99999}}, 81234],
  24. ]
  25. for inputs, expected in cases:
  26. with self.subTest(inputs):
  27. parser = self.makeParser(**inputs)
  28. with instrumentGooey(parser) as (app, gooeyApp):
  29. slider = gooeyApp.configs[0].reifiedWidgets[0]
  30. self.assertEqual(slider.getValue()['rawValue'], expected)
  31. if __name__ == '__main__':
  32. unittest.main()