mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-12-02 14:22:34 +00:00
length min/max
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user