2013-11-06 19:38:30 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
Test Salt's argument parser
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting import TestCase
|
|
|
|
from salttesting.helpers import ensure_in_syspath, requires_salt_modules
|
|
|
|
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import Salt libs
|
|
|
|
from salt.exceptions import SaltInvocationError
|
|
|
|
import integration
|
|
|
|
|
|
|
|
|
2013-11-06 20:00:02 +00:00
|
|
|
@requires_salt_modules('test.ping', 'test.arg')
|
2013-11-06 19:38:30 +00:00
|
|
|
class ArgumentTestCase(integration.ModuleCase):
|
|
|
|
def test_unsupported_kwarg(self):
|
|
|
|
'''
|
2013-11-06 20:03:33 +00:00
|
|
|
Test passing a non-supported keyword argument. The relevant code that
|
|
|
|
checks for invalid kwargs is located in salt/minion.py, within the
|
|
|
|
'parse_args_and_kwargs' function.
|
2013-11-06 19:38:30 +00:00
|
|
|
'''
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('test.ping', ['foo=bar']),
|
|
|
|
("ERROR executing 'test.ping': The following keyword arguments "
|
|
|
|
"are not valid: foo=bar")
|
|
|
|
)
|
|
|
|
|
2013-11-06 20:00:02 +00:00
|
|
|
def test_kwarg_name_containing_dashes(self):
|
|
|
|
'''
|
|
|
|
Tests the arg parser to ensure that kwargs with dashes in the arg name
|
|
|
|
are properly identified as kwargs. If this fails, then the KWARG_REGEX
|
2013-11-06 20:03:33 +00:00
|
|
|
variable in salt/utils/__init__.py needs to be fixed.
|
2013-11-06 20:00:02 +00:00
|
|
|
'''
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'test.arg', ['foo-bar=baz']
|
|
|
|
).get('kwargs', {}).get('foo-bar'),
|
|
|
|
'baz'
|
|
|
|
)
|
2013-11-06 19:38:30 +00:00
|
|
|
|
2013-11-06 20:03:33 +00:00
|
|
|
|
2013-11-06 19:38:30 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(ArgumentTestCase)
|