2013-11-09 10:26:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
|
|
|
|
|
|
|
|
|
|
unit.utils.kwarg_regex_test
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
'''
|
|
|
|
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Pytohn libs
|
2018-01-12 03:54:29 +00:00
|
|
|
from __future__ import absolute_import, unicode_literals
|
2014-11-21 19:05:13 +00:00
|
|
|
|
2013-11-09 10:26:28 +00:00
|
|
|
# Import Salt Testing libs
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import TestCase
|
2013-11-09 10:26:28 +00:00
|
|
|
|
|
|
|
# Import Salt libs
|
2014-03-21 15:45:23 +00:00
|
|
|
from salt.utils.args import KWARG_REGEX
|
2013-11-09 10:26:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class KwargRegexTest(TestCase):
|
|
|
|
def test_arguments_regex(self):
|
|
|
|
argument_matches = (
|
|
|
|
('pip=1.1', ('pip', '1.1')),
|
|
|
|
('pip==1.1', None),
|
|
|
|
('pip=1.2=1', ('pip', '1.2=1')),
|
|
|
|
)
|
|
|
|
for argument, match in argument_matches:
|
|
|
|
if match is None:
|
|
|
|
self.assertIsNone(KWARG_REGEX.match(argument))
|
|
|
|
else:
|
|
|
|
self.assertEqual(
|
|
|
|
KWARG_REGEX.match(argument).groups(), match
|
|
|
|
)
|