MCPcopy Create free account
hub / github.com/StackStorm/st2 / test_regex

Method test_regex

st2common/tests/unit/test_operators.py:834–866  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

832 self.assertFalse(op("1", None), "Passed iregex with None as criteria_pattern.")
833
834 def test_regex(self):
835 op = operators.get_operator("regex")
836 self.assertTrue(op("v1", "v1$"), "Failed regex.")
837
838 string = "fooponiesbarfooooo"
839 self.assertTrue(op(string, "ponies"), "Failed regex.")
840
841 # Example with | modifier
842 string = "apple ponies oranges"
843 self.assertTrue(op(string, "(ponies|unicorns)"), "Failed regex.")
844
845 string = "apple unicorns oranges"
846 self.assertTrue(op(string, "(ponies|unicorns)"), "Failed regex.")
847
848 # Mixing bytes and strings / unicode should still work
849 self.assertTrue(
850 op(b"apples unicorns oranges", "(ponies|unicorns)"), "Failed regex."
851 )
852 self.assertTrue(
853 op("apples unicorns oranges", b"(ponies|unicorns)"), "Failed regex."
854 )
855 self.assertTrue(
856 op(b"apples unicorns oranges", b"(ponies|unicorns)"), "Failed regex."
857 )
858 self.assertTrue(
859 op(b"apples unicorns oranges", "(ponies|unicorns)"), "Failed regex."
860 )
861 self.assertTrue(
862 op("apples unicorns oranges", "(ponies|unicorns)"), "Failed regex."
863 )
864
865 string = "apple unicorns oranges"
866 self.assertFalse(op(string, "(pikachu|snorlax|charmander)"), "Passed regex.")
867
868 def test_regex_fail(self):
869 op = operators.get_operator("regex")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected