1
0

test_data.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. 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. def test_load_dump(self):
  14. '''
  15. data.load
  16. data.dump
  17. '''
  18. self.assertTrue(self.run_function('data.dump', ['{"foo": "bar"}']))
  19. self.assertEqual(self.run_function('data.load'), {'foo': 'bar'})
  20. def test_get_update(self):
  21. '''
  22. data.get
  23. data.update
  24. '''
  25. self.assertTrue(self.run_function('data.update', ['spam', 'eggs']))
  26. self.assertEqual(self.run_function('data.get', ['spam']), 'eggs')
  27. self.assertTrue(self.run_function('data.update', ['unladen', 'swallow']))
  28. self.assertEqual(self.run_function('data.get', [["spam", "unladen"]]), ['eggs', 'swallow'])
  29. def test_cas_update(self):
  30. '''
  31. data.update
  32. data.cas
  33. data.get
  34. '''
  35. self.assertTrue(self.run_function('data.update', ['spam', 'eggs']))
  36. self.assertTrue(self.run_function('data.cas', ['spam', 'green', 'eggs']))
  37. self.assertEqual(self.run_function('data.get', ['spam']), 'green')