2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2013-06-27 10:43:43 +00:00
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-04-04 04:30:38 +00:00
|
|
|
# Import salt libs
|
2013-06-27 10:43:43 +00:00
|
|
|
import integration
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-04-04 04:30:38 +00:00
|
|
|
|
|
|
|
class StdTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Test standard client calls
|
|
|
|
'''
|
|
|
|
def test_cli(self):
|
|
|
|
'''
|
|
|
|
Test cli function
|
|
|
|
'''
|
|
|
|
cmd_iter = self.client.cmd_cli(
|
|
|
|
'minion',
|
|
|
|
'test.kwarg',
|
|
|
|
['foo=bar', 'baz=quo'],
|
|
|
|
kwarg={'qux': 'quux'}
|
|
|
|
)
|
|
|
|
for ret in cmd_iter:
|
|
|
|
data = ret['minion']['ret']
|
|
|
|
self.assertIn('foo', data)
|
|
|
|
self.assertIn('baz', data)
|
|
|
|
self.assertIn('qux', data)
|
|
|
|
self.assertEqual(data['foo'], 'bar')
|
|
|
|
self.assertEqual(data['baz'], 'quo')
|
|
|
|
self.assertEqual(data['qux'], 'quux')
|
|
|
|
|
|
|
|
def test_iter(self):
|
|
|
|
'''
|
|
|
|
test cmd_iter
|
|
|
|
'''
|
|
|
|
cmd_iter = self.client.cmd_iter(
|
|
|
|
'minion',
|
|
|
|
'test.kwarg',
|
|
|
|
['foo=bar', 'baz=quo'],
|
|
|
|
kwarg={'qux': 'quux'}
|
|
|
|
)
|
|
|
|
for ret in cmd_iter:
|
|
|
|
data = ret['minion']['ret']
|
|
|
|
self.assertIn('foo', data)
|
|
|
|
self.assertIn('baz', data)
|
|
|
|
self.assertIn('qux', data)
|
|
|
|
self.assertEqual(data['foo'], 'bar')
|
|
|
|
self.assertEqual(data['baz'], 'quo')
|
|
|
|
self.assertEqual(data['qux'], 'quux')
|
|
|
|
|
|
|
|
def test_iter_no_block(self):
|
|
|
|
'''
|
|
|
|
test cmd_iter_no_block
|
|
|
|
'''
|
|
|
|
cmd_iter = self.client.cmd_iter_no_block(
|
|
|
|
'minion',
|
|
|
|
'test.kwarg',
|
|
|
|
['foo=bar', 'baz=quo'],
|
|
|
|
kwarg={'qux': 'quux'}
|
|
|
|
)
|
|
|
|
for ret in cmd_iter:
|
|
|
|
if ret is None:
|
|
|
|
continue
|
|
|
|
data = ret['minion']['ret']
|
|
|
|
self.assertIn('foo', data)
|
|
|
|
self.assertIn('baz', data)
|
|
|
|
self.assertIn('qux', data)
|
|
|
|
self.assertEqual(data['foo'], 'bar')
|
|
|
|
self.assertEqual(data['baz'], 'quo')
|
|
|
|
self.assertEqual(data['qux'], 'quux')
|
|
|
|
|
|
|
|
def test_full_returns(self):
|
|
|
|
'''
|
|
|
|
test cmd_iter
|
|
|
|
'''
|
|
|
|
ret = self.client.cmd_full_return(
|
|
|
|
'minion',
|
|
|
|
'test.kwarg',
|
|
|
|
['foo=bar', 'baz=quo'],
|
|
|
|
kwarg={'qux': 'quux'}
|
|
|
|
)
|
|
|
|
data = ret['minion']
|
2012-05-28 03:43:35 +00:00
|
|
|
self.assertIn('foo', data['ret'])
|
|
|
|
self.assertIn('baz', data['ret'])
|
|
|
|
self.assertIn('qux', data['ret'])
|
|
|
|
self.assertEqual(data['ret']['foo'], 'bar')
|
|
|
|
self.assertEqual(data['ret']['baz'], 'quo')
|
|
|
|
self.assertEqual(data['ret']['qux'], 'quux')
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2013-11-06 02:55:53 +00:00
|
|
|
def test_kwarg_type(self):
|
|
|
|
'''
|
|
|
|
Test that kwargs end up on the client as the same type
|
|
|
|
'''
|
|
|
|
terrible_yaml_string = 'foo: ""\n# \''
|
|
|
|
ret = self.client.cmd_full_return(
|
|
|
|
'minion',
|
|
|
|
'test.arg_type',
|
|
|
|
['a', 1],
|
|
|
|
kwarg={'outer': {'a': terrible_yaml_string},
|
|
|
|
'inner': 'value'}
|
|
|
|
)
|
|
|
|
data = ret['minion']['ret']
|
|
|
|
self.assertIn('str', data['args'][0])
|
|
|
|
self.assertIn('int', data['args'][1])
|
|
|
|
self.assertIn('dict', data['kwargs']['outer'])
|
|
|
|
self.assertIn('str', data['kwargs']['inner'])
|
|
|
|
|
2013-06-27 10:43:43 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-06-24 22:53:59 +00:00
|
|
|
from integration import run_tests
|
|
|
|
run_tests(StdTest)
|