diff --git a/changedetectionio/conditions/default_plugin.py b/changedetectionio/conditions/default_plugin.py index 5668bdb4..d0554ad0 100644 --- a/changedetectionio/conditions/default_plugin.py +++ b/changedetectionio/conditions/default_plugin.py @@ -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 diff --git a/changedetectionio/tests/test_conditions.py b/changedetectionio/tests/test_conditions.py index 7972ece8..1116d973 100644 --- a/changedetectionio/tests/test_conditions.py +++ b/changedetectionio/tests/test_conditions.py @@ -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 )