data.py code deprecations and minor test changes

This commit is contained in:
justinta89 2016-02-05 15:11:26 -07:00
parent 7a02890774
commit 7a4be37c06
3 changed files with 17 additions and 96 deletions

View File

@ -102,48 +102,6 @@ def update(key, value):
return True
def getval(key):
'''
Get a value from the minion datastore
.. deprecated:: Boron
Use ``get`` instead
CLI Example:
.. code-block:: bash
salt '*' data.getval <key>
'''
salt.utils.warn_until(
'Boron',
'Support for \'getval\' has been deprecated and will be removed '
'in Salt Boron. Please use \'get\' instead.'
)
return get(key)
def getvals(*keylist):
'''
Get values from the minion datastore
.. deprecated:: Boron
Use ``get`` instead
CLI Example:
.. code-block:: bash
salt '*' data.getvals <key> [<key> ...]
'''
salt.utils.warn_until(
'Boron',
'Support for \'getvals\' has been deprecated and will be removed '
'in Salt Boron. Please use \'get\' instead.'
)
return get(keylist)
def cas(key, value, old_value):
'''
Check and set a value in the minion datastore
@ -194,7 +152,8 @@ def get(key, default=None):
.. code-block:: bash
salt '*' data.get <key(s)>
salt '*' data.get <key>
salt '*' data.get '["key1", "key2"]'
'''
store = load()

View File

@ -33,65 +33,27 @@ class DataModuleTest(integration.ModuleCase):
def test_get_update(self):
'''
data.getval
data.get
data.update
data.getvals
'''
self._clear_db()
self.assertTrue(
self.run_function(
'data.update',
['spam', 'eggs']
)
)
self.assertEqual(
self.run_function(
'data.getval',
['spam']
),
'eggs'
)
self.assertTrue(
self.run_function(
'data.update',
['unladen', 'swallow']
)
)
self.assertEqual(
self.run_function(
'data.getvals',
['spam', 'unladen']
),
['eggs', 'swallow']
)
self.assertTrue(self.run_function('data.update', ['spam', 'eggs']))
self.assertEqual(self.run_function('data.get', ['spam']), 'eggs')
self.assertTrue(self.run_function('data.update', ['unladen', 'swallow']))
self.assertEqual(self.run_function('data.get', ['["spam", "unladen"]']), ['eggs', 'swallow'])
self._clear_db()
def test_cas_update(self):
'''
data.update
data.cas
data.getval
data.get
'''
self._clear_db()
self.assertTrue(
self.run_function(
'data.update',
['spam', 'eggs']
)
)
self.assertTrue(
self.run_function(
'data.cas',
['spam', 'green', 'eggs']
)
)
self.assertEqual(
self.run_function(
'data.getval',
['spam']
),
'green'
)
self.assertTrue(self.run_function('data.update', ['spam', 'eggs']))
self.assertTrue(self.run_function('data.cas', ['spam', 'green', 'eggs']))
self.assertEqual(self.run_function('data.get', ['spam']), 'green')
if __name__ == '__main__':
from integration import run_tests

View File

@ -93,9 +93,9 @@ class DataTestCase(TestCase):
# 'getval' function tests: 1
@patch('salt.modules.data.load', MagicMock(return_value={'salt': 'SALT'}))
def test_getval(self):
def test_get(self):
'''
Test if it get a value from the minion datastore
Test if it gets a value from the minion datastore
'''
self.assertEqual(data.getval('salt'), 'SALT')
@ -103,11 +103,11 @@ class DataTestCase(TestCase):
@patch('salt.modules.data.load',
MagicMock(return_value={'salt': 'SALT', 'salt1': 'SALT1'}))
def test_getvals(self):
def test_get_vals(self):
'''
Test if it get a values from the minion datastore
Test if it gets values from the minion datastore
'''
self.assertEqual(data.getvals('salt', 'salt1'), ['SALT', 'SALT1'])
self.assertEqual(data.getvals(['salt', 'salt1']), ['SALT', 'SALT1'])
# 'cas' function tests: 1