1
0

test_data.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Testing libs
  5. from tests.support.case import ModuleCase
  6. import pytest
  7. @pytest.mark.windows_whitelisted
  8. class DataModuleTest(ModuleCase):
  9. '''
  10. Validate the data module
  11. '''
  12. def setUp(self):
  13. self.run_function('data.clear')
  14. self.addCleanup(self.run_function, 'data.clear')
  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. 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(self.run_function('data.get', [["spam", "unladen"]]), ['eggs', 'swallow'])
  31. def test_cas_update(self):
  32. '''
  33. data.update
  34. data.cas
  35. data.get
  36. '''
  37. self.assertTrue(self.run_function('data.update', ['spam', 'eggs']))
  38. self.assertTrue(self.run_function('data.cas', ['spam', 'green', 'eggs']))
  39. self.assertEqual(self.run_function('data.get', ['spam']), 'green')