length min/max

This commit is contained in:
dgtlmoon
2025-03-17 18:03:28 +01:00
parent 42099f1fff
commit cc70b65bfa
2 changed files with 20 additions and 1 deletions

View File

@@ -13,9 +13,17 @@ def register_operators():
def ends_with(_, text, suffix):
return text.lower().strip().endswith(str(suffix).strip().lower())
def length_min(_, text, strlen):
return len(text) >= int(strlen)
def length_max(_, text, strlen):
return len(text) <= int(strlen)
return {
"starts_with": starts_with,
"ends_with": ends_with
"ends_with": ends_with,
"length_min": length_min,
"length_max": length_max
}
@hookimpl
@@ -23,6 +31,8 @@ def register_operator_choices():
return [
("starts_with", "Text Starts With"),
("ends_with", "Text Ends With"),
("length_min", "Length minimum"),
("length_max", "Length maximum"),
]
@hookimpl

View File

@@ -84,6 +84,15 @@ def test_conditions_with_text_and_number(client, live_server):
"conditions-2-field": "extracted_number",
"conditions-2-value": "100",
# So that 'operations' from pluggy discovery are tested
"conditions-3-operator": "length_min",
"conditions-3-field": "page_filtered_text",
"conditions-3-value": "1",
# So that 'operations' from pluggy discovery are tested
"conditions-4-operator": "length_max",
"conditions-4-field": "page_filtered_text",
"conditions-4-value": "100",
},
follow_redirects=True
)