summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2019-03-06 17:49:40 +0100
committerGitHub <noreply@github.com>2019-03-06 17:49:40 +0100
commitd241794daa6d413e6447890e2a4f11e0d818cf0e (patch)
treeeb20525d2fe564d98a393296a8a543324b0fdc76 /test
parentBug Fix: na_elementsw_cluster_pair.py check if clusters are allready paired (... (diff)
downloadansible-d241794daa6d413e6447890e2a4f11e0d818cf0e.tar.xz
ansible-d241794daa6d413e6447890e2a4f11e0d818cf0e.zip
Add toggle to control invalid character substitution in group names (#52748)
* make add_group return proper name * ensure central transform/check * added 'silent' option to avoid spamming current users those already using the plugins were used to the transformations, so no need to alert them * centralized valid var names * dont display dupes * comment on regex * added regex tests ini and script will now warn about deprecation * more complete errormsg
Diffstat (limited to 'test')
-rw-r--r--test/units/regex/test_invalid_var_names.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/units/regex/test_invalid_var_names.py b/test/units/regex/test_invalid_var_names.py
new file mode 100644
index 0000000000..d47e68d3e5
--- /dev/null
+++ b/test/units/regex/test_invalid_var_names.py
@@ -0,0 +1,27 @@
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from units.compat import unittest
+
+from ansible import constants as C
+
+
+test_cases = (('not-valid', ['-'], 'not_valid'), ('not!valid@either', ['!', '@'], 'not_valid_either'), ('1_nor_This', ['1'], '__nor_This'))
+
+
+class TestInvalidVars(unittest.TestCase):
+
+ def test_positive_matches(self):
+
+ for name, invalid, sanitized in test_cases:
+ self.assertEqual(C.INVALID_VARIABLE_NAMES.findall(name), invalid)
+
+ def test_negative_matches(self):
+ for name in ('this_is_valid', 'Also_1_valid', 'noproblem'):
+ self.assertEqual(C.INVALID_VARIABLE_NAMES.findall(name), [])
+
+ def test_get_setting(self):
+
+ for name, invalid, sanitized in test_cases:
+ self.assertEqual(C.INVALID_VARIABLE_NAMES.sub('_', name), sanitized)