salt/tests/unit/modules/test_sdb.py

46 lines
1.1 KiB
Python
Raw Normal View History

2015-02-17 12:50:58 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
'''
# Import Python Libs
from __future__ import absolute_import
# Import Salt Testing Libs
2017-03-21 17:57:27 +00:00
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.mock import (
2015-02-17 12:50:58 +00:00
NO_MOCK,
NO_MOCK_REASON
)
# Import Salt Libs
import salt.modules.sdb as sdb
2015-02-17 12:50:58 +00:00
@skipIf(NO_MOCK, NO_MOCK_REASON)
2017-03-21 17:57:27 +00:00
class SdbTestCase(TestCase, LoaderModuleMockMixin):
2015-02-17 12:50:58 +00:00
'''
Test cases for salt.modules.sdb
'''
def setup_loader_modules(self):
return {sdb: {}}
2015-02-17 12:50:58 +00:00
# 'get' function tests: 1
def test_get(self):
'''
Test if it gets a value from a db, using a uri in the form of
sdb://<profile>/<key>
'''
self.assertEqual(sdb.get('sdb://salt/foo'), 'sdb://salt/foo')
# 'set_' function tests: 1
def test_set(self):
'''
Test if it sets a value from a db, using a uri in the form of
sdb://<profile>/<key>
'''
self.assertFalse(sdb.set_('sdb://mymemcached/foo', 'bar'))