test_sdb.py 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Libs
  8. import salt.modules.sdb as sdb
  9. # Import Salt Testing Libs
  10. from tests.support.mixins import LoaderModuleMockMixin
  11. from tests.support.unit import TestCase
  12. class SdbTestCase(TestCase, LoaderModuleMockMixin):
  13. """
  14. Test cases for salt.modules.sdb
  15. """
  16. def setup_loader_modules(self):
  17. return {sdb: {}}
  18. # 'get' function tests: 1
  19. def test_get(self):
  20. """
  21. Test if it gets a value from a db, using a uri in the form of
  22. sdb://<profile>/<key>
  23. """
  24. self.assertEqual(sdb.get("sdb://salt/foo"), "sdb://salt/foo")
  25. # 'set_' function tests: 1
  26. def test_set(self):
  27. """
  28. Test if it sets a value from a db, using a uri in the form of
  29. sdb://<profile>/<key>
  30. """
  31. self.assertFalse(sdb.set_("sdb://mymemcached/foo", "bar"))