mirror of
				https://github.com/dgtlmoon/changedetection.io.git
				synced 2025-10-31 06:37:41 +00:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			0.50.19
			...
			API-condit
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | bc20ac2685 | ||
|   | 0ae1b76d20 | 
| @@ -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. | ||||
|   | ||||
| @@ -292,9 +292,7 @@ def test_access_denied(client, live_server, measure_memory_usage): | ||||
|  | ||||
| def test_api_watch_PUT_update(client, live_server, measure_memory_usage): | ||||
|  | ||||
|      | ||||
|     api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') | ||||
|  | ||||
|     # Create a watch | ||||
|     set_original_response() | ||||
|     test_url = url_for('test_endpoint', _external=True) | ||||
| @@ -302,14 +300,27 @@ def test_api_watch_PUT_update(client, live_server, measure_memory_usage): | ||||
|     # Create new | ||||
|     res = client.post( | ||||
|         url_for("createwatch"), | ||||
|         data=json.dumps({"url": test_url, 'tag': "One, Two", "title": "My test URL", 'headers': {'cookie': 'yum'} }), | ||||
|         data=json.dumps({"url": test_url, | ||||
|                          'tag': "One, Two", | ||||
|                          "title": "My test URL", | ||||
|                          'headers': {'cookie': 'yum'}, | ||||
|                          "conditions": [ | ||||
|                              { | ||||
|                                  "field": "page_filtered_text", | ||||
|                                  "operator": "contains_regex", | ||||
|                                  "value": "."  # contains anything | ||||
|                              } | ||||
|                          ], | ||||
|                          "conditions_match_logic": "ALL" | ||||
|                          } | ||||
|                         ), | ||||
|         headers={'content-type': 'application/json', 'x-api-key': api_key}, | ||||
|         follow_redirects=True | ||||
|     ) | ||||
|  | ||||
|     assert res.status_code == 201 | ||||
|  | ||||
|  | ||||
|     wait_for_all_checks(client) | ||||
|     # Get a listing, it will be the first one | ||||
|     res = client.get( | ||||
|         url_for("createwatch"), | ||||
|   | ||||
| @@ -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"""<html> | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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"}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user