From 0ae1b76d20793b64d2a7d5f27663c8ac4a27df4b Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 30 Jul 2025 13:39:01 +0200 Subject: [PATCH] Fix set conditions by API re #3348 --- changedetectionio/model/__init__.py | 3 +++ changedetectionio/tests/test_conditions.py | 6 ++++-- changedetectionio/tests/unit/test_conditions.py | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/changedetectionio/model/__init__.py b/changedetectionio/model/__init__.py index 2a6587aa2..54b9ef18e 100644 --- a/changedetectionio/model/__init__.py +++ b/changedetectionio/model/__init__.py @@ -3,6 +3,7 @@ import uuid from changedetectionio import strtobool default_notification_format_for_watch = 'System default' +CONDITIONS_MATCH_LOGIC_DEFAULT = 'ALL' class watch_base(dict): @@ -15,6 +16,8 @@ class watch_base(dict): 'body': None, 'browser_steps': [], 'browser_steps_last_error_step': None, + 'conditions' : {}, + 'conditions_match_logic': CONDITIONS_MATCH_LOGIC_DEFAULT, 'check_count': 0, 'check_unique_lines': False, # On change-detected, compare against all history if its something new 'consecutive_filter_failures': 0, # Every time the CSS/xPath filter cannot be located, reset when all is fine. diff --git a/changedetectionio/tests/test_conditions.py b/changedetectionio/tests/test_conditions.py index 9c6fae45d..e83dc0c8e 100644 --- a/changedetectionio/tests/test_conditions.py +++ b/changedetectionio/tests/test_conditions.py @@ -4,6 +4,8 @@ import time from flask import url_for from .util import live_server_setup, wait_for_all_checks +from ..model import CONDITIONS_MATCH_LOGIC_DEFAULT + def set_original_response(number="50"): test_return_data = f""" @@ -76,7 +78,7 @@ def test_conditions_with_text_and_number(client, live_server): "fetch_backend": "html_requests", "include_filters": ".number-container", "title": "Number AND Text Condition Test", - "conditions_match_logic": "ALL", # ALL = AND logic + "conditions_match_logic": CONDITIONS_MATCH_LOGIC_DEFAULT, # ALL = AND logic "conditions-0-operator": "in", "conditions-0-field": "page_filtered_text", "conditions-0-value": "5", @@ -283,7 +285,7 @@ def test_lev_conditions_plugin(client, live_server, measure_memory_usage): data={ "url": test_url, "fetch_backend": "html_requests", - "conditions_match_logic": "ALL", # ALL = AND logic + "conditions_match_logic": CONDITIONS_MATCH_LOGIC_DEFAULT, # ALL = AND logic "conditions-0-field": "levenshtein_ratio", "conditions-0-operator": "<", "conditions-0-value": "0.8" # needs to be more of a diff to trigger a change diff --git a/changedetectionio/tests/unit/test_conditions.py b/changedetectionio/tests/unit/test_conditions.py index 0de147cf2..06ddfea30 100644 --- a/changedetectionio/tests/unit/test_conditions.py +++ b/changedetectionio/tests/unit/test_conditions.py @@ -1,4 +1,5 @@ from changedetectionio.conditions import execute_ruleset_against_all_plugins +from changedetectionio.model import CONDITIONS_MATCH_LOGIC_DEFAULT from changedetectionio.store import ChangeDetectionStore import shutil import tempfile @@ -59,7 +60,7 @@ class TestTriggerConditions(unittest.TestCase): self.store.data['watching'][self.watch_uuid].update( { - "conditions_match_logic": "ALL", + "conditions_match_logic": CONDITIONS_MATCH_LOGIC_DEFAULT, "conditions": [ {"operator": ">=", "field": "extracted_number", "value": "10"}, {"operator": "<=", "field": "extracted_number", "value": "5000"},