From 7060e9bc02fdf53a6dc116ef929239de2d6f21fa Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 11 Feb 2026 06:17:17 +0100 Subject: [PATCH] Include missing `tags` reply Re #3854 --- changedetectionio/api/Watch.py | 1 + changedetectionio/tests/test_api_tags.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/changedetectionio/api/Watch.py b/changedetectionio/api/Watch.py index 7d04911cf..fbd3ac827 100644 --- a/changedetectionio/api/Watch.py +++ b/changedetectionio/api/Watch.py @@ -481,6 +481,7 @@ class CreateWatch(Resource): 'last_error': watch['last_error'], 'link': watch.link, 'page_title': watch['page_title'], + 'tags': list(tags.keys()), 'title': watch['title'], 'url': watch['url'], 'viewed': watch.viewed diff --git a/changedetectionio/tests/test_api_tags.py b/changedetectionio/tests/test_api_tags.py index bd2695827..5a5253939 100644 --- a/changedetectionio/tests/test_api_tags.py +++ b/changedetectionio/tests/test_api_tags.py @@ -18,7 +18,7 @@ def test_api_tags_listing(client, live_server, measure_memory_usage, datastore_p url_for("tags"), headers={'x-api-key': api_key} ) - assert res.text.strip() == "{}", "Should be empty list" + assert res.get_data(as_text=True).strip() == "{}", "Should be empty list" assert res.status_code == 200 res = client.post( @@ -36,7 +36,7 @@ def test_api_tags_listing(client, live_server, measure_memory_usage, datastore_p headers={'x-api-key': api_key} ) assert res.status_code == 200 - assert new_tag_uuid in res.text + assert new_tag_uuid in res.get_data(as_text=True) assert res.json[new_tag_uuid]['title'] == tag_title assert res.json[new_tag_uuid]['notification_muted'] == False @@ -118,6 +118,16 @@ def test_api_tags_listing(client, live_server, measure_memory_usage, datastore_p assert res.status_code == 200 assert new_tag_uuid in res.json.get('tags', []) + # Test that tags are returned when listing ALL watches (issue #3854) + res = client.get( + url_for("createwatch"), # GET /api/v1/watch - list all watches + headers={'x-api-key': api_key} + ) + assert res.status_code == 200 + assert watch_uuid in res.json, "Watch should be in the list" + assert 'tags' in res.json[watch_uuid], "Tags field should be present in watch list" + assert new_tag_uuid in res.json[watch_uuid]['tags'], "Tag UUID should be in tags array" + # Check recheck by tag before_check_time = live_server.app.config['DATASTORE'].data['watching'][watch_uuid].get('last_checked') time.sleep(1) @@ -148,7 +158,7 @@ def test_api_tags_listing(client, live_server, measure_memory_usage, datastore_p headers={'x-api-key': api_key} ) assert res.status_code == 200 - assert new_tag_uuid not in res.text + assert new_tag_uuid not in res.get_data(as_text=True) # Verify tag was removed from watch res = client.get(