Add new text pattern parameter (#7025)

Co-authored-by: Ezra Odio <eodio@starfishstorage.com>
Co-authored-by: Restyled.io <commits@restyled.io>
This commit is contained in:
Ezra Odio
2024-07-24 13:20:33 -04:00
committed by GitHub
parent c244e75352
commit a69f7fb2fe
12 changed files with 322 additions and 191 deletions

View File

@@ -73,6 +73,21 @@ class TestParameterizedQuery(TestCase):
self.assertEqual("foo baz", query.text)
def test_validates_text_pattern_parameters(self):
schema = [{"name": "bar", "type": "text-pattern", "regex": "a+"}]
query = ParameterizedQuery("foo {{bar}}", schema)
query.apply({"bar": "a"})
self.assertEqual("foo a", query.text)
def test_raises_on_invalid_text_pattern_parameters(self):
schema = schema = [{"name": "bar", "type": "text-pattern", "regex": "a+"}]
query = ParameterizedQuery("foo {{bar}}", schema)
with pytest.raises(InvalidParameterError):
query.apply({"bar": "b"})
def test_raises_on_invalid_number_parameters(self):
schema = [{"name": "bar", "type": "number"}]
query = ParameterizedQuery("foo", schema)