test_data.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, print_function, unicode_literals
  3. import pytest
  4. from tests.support.case import ModuleCase
  5. @pytest.mark.windows_whitelisted
  6. class DataModuleTest(ModuleCase):
  7. """
  8. Validate the data module
  9. """
  10. def setUp(self):
  11. self.run_function("data.clear")
  12. self.addCleanup(self.run_function, "data.clear")
  13. @pytest.mark.slow_test(seconds=60) # Test takes >30 and <=60 seconds
  14. def test_load_dump(self):
  15. """
  16. data.load
  17. data.dump
  18. """
  19. self.assertTrue(self.run_function("data.dump", ['{"foo": "bar"}']))
  20. self.assertEqual(self.run_function("data.load"), {"foo": "bar"})
  21. @pytest.mark.slow_test(seconds=120) # Test takes >60 and <=120 seconds
  22. def test_get_update(self):
  23. """
  24. data.get
  25. data.update
  26. """
  27. self.assertTrue(self.run_function("data.update", ["spam", "eggs"]))
  28. self.assertEqual(self.run_function("data.get", ["spam"]), "eggs")
  29. self.assertTrue(self.run_function("data.update", ["unladen", "swallow"]))
  30. self.assertEqual(
  31. self.run_function("data.get", [["spam", "unladen"]]), ["eggs", "swallow"]
  32. )
  33. @pytest.mark.slow_test(seconds=60) # Test takes >30 and <=60 seconds
  34. def test_cas_update(self):
  35. """
  36. data.update
  37. data.cas
  38. data.get
  39. """
  40. self.assertTrue(self.run_function("data.update", ["spam", "eggs"]))
  41. self.assertTrue(self.run_function("data.cas", ["spam", "green", "eggs"]))
  42. self.assertEqual(self.run_function("data.get", ["spam"]), "green")