Volans has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/345402 )

Change subject: Do not auto-ucfirst when the query is a regex
......................................................................

Do not auto-ucfirst when the query is a regex

Bug: T161730
Change-Id: I7591230167fc6dee01f1e17e87de120f9c67f027
---
M cumin/backends/puppetdb.py
M cumin/tests/unit/backends/test_puppetdb.py
2 files changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/software/cumin 
refs/changes/02/345402/1

diff --git a/cumin/backends/puppetdb.py b/cumin/backends/puppetdb.py
index 4506583..28df0ea 100644
--- a/cumin/backends/puppetdb.py
+++ b/cumin/backends/puppetdb.py
@@ -150,7 +150,7 @@
 
         else:
             # Querying a specific resource title
-            if key.lower() == 'class':
+            if key.lower() == 'class' and operator != '~':
                 value = capwords(value, '::')  # Auto ucfirst the class title
             query_part = ', ["{op}", "title", "{value}"]'.format(op=operator, 
value=value)
 
diff --git a/cumin/tests/unit/backends/test_puppetdb.py 
b/cumin/tests/unit/backends/test_puppetdb.py
index 436e1ef..dbe2826 100644
--- a/cumin/tests/unit/backends/test_puppetdb.py
+++ b/cumin/tests/unit/backends/test_puppetdb.py
@@ -109,6 +109,12 @@
         self.assertListEqual(self.query.current_group['tokens'],
                              [r'["and", ["=", "type", "Key"], ["~", "title", 
"value\\\\escaped"]]'])
 
+    def test_add_category_resource_class_regex(self):
+        """Calling add_category() with a regex Class resource query should add 
the proper query token to the object."""
+        self.query.add_category('R', 'Class', r'Role::(One|Another)', 
operator='~')
+        self.assertListEqual(self.query.current_group['tokens'],
+                             [r'["and", ["=", "type", "Class"], ["~", "title", 
"Role::(One|Another)"]]'])
+
     def test_add_category_resource_parameter(self):
         """Calling add_category() with a resource's parameter query should add 
the proper query token to the object."""
         self.query.add_category('R', 'resource%param', 'value')

-- 
To view, visit https://gerrit.wikimedia.org/r/345402
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7591230167fc6dee01f1e17e87de120f9c67f027
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/cumin
Gerrit-Branch: master
Gerrit-Owner: Volans <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to