test_data.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. from tests.support.helpers import slowTest
  6. @pytest.mark.windows_whitelisted
  7. class DataModuleTest(ModuleCase):
  8. """
  9. Validate the data module
  10. """
  11. def setUp(self):
  12. self.run_function("data.clear")
  13. self.addCleanup(self.run_function, "data.clear")
  14. @slowTest
  15. def test_load_dump(self):
  16. """
  17. data.load
  18. data.dump
  19. """
  20. self.assertTrue(self.run_function("data.dump", ['{"foo": "bar"}']))
  21. self.assertEqual(self.run_function("data.load"), {"foo": "bar"})
  22. @slowTest
  23. def test_get_update(self):
  24. """
  25. data.get
  26. data.update
  27. """
  28. self.assertTrue(self.run_function("data.update", ["spam", "eggs"]))
  29. self.assertEqual(self.run_function("data.get", ["spam"]), "eggs")
  30. self.assertTrue(self.run_function("data.update", ["unladen", "swallow"]))
  31. self.assertEqual(
  32. self.run_function("data.get", [["spam", "unladen"]]), ["eggs", "swallow"]
  33. )
  34. @slowTest
  35. def test_cas_update(self):
  36. """
  37. data.update
  38. data.cas
  39. data.get
  40. """
  41. self.assertTrue(self.run_function("data.update", ["spam", "eggs"]))
  42. self.assertTrue(self.run_function("data.cas", ["spam", "green", "eggs"]))
  43. self.assertEqual(self.run_function("data.get", ["spam"]), "green")