Adding test, fixing

3356-API-recheck-by-tag
dgtlmoon 2025-08-19 18:05:46 +02:00
rodzic 83f35e98e4
commit 0c892387b3
2 zmienionych plików z 26 dodań i 3 usunięć

Wyświetl plik

@ -47,7 +47,7 @@ class Tag(Resource):
for k in sorted(self.datastore.data['watching'].items(), key=lambda item: item[1].get('last_checked', 0)):
watch_uuid = k[0]
watch = k[1]
if not watch['paused'] and tag not in watch['tags']:
if not watch['paused'] and tag['uuid'] not in watch['tags']:
continue
worker_handler.queue_item_async_safe(self.update_q, queuedWatchMetaData.PrioritizedItem(priority=1, item={'uuid': watch_uuid}))
i+=1

Wyświetl plik

@ -1,15 +1,18 @@
#!/usr/bin/env python3
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
from .util import live_server_setup, wait_for_all_checks, set_original_response
import json
import time
def test_api_tags_listing(client, live_server, measure_memory_usage):
# live_server_setup(live_server) # Setup on conftest per function
api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token')
tag_title = 'Test Tag'
# Get a listing
set_original_response()
res = client.get(
url_for("tags"),
headers={'x-api-key': api_key}
@ -104,6 +107,8 @@ def test_api_tags_listing(client, live_server, measure_memory_usage):
assert res.status_code == 201
watch_uuid = res.json.get('uuid')
wait_for_all_checks()
# Verify tag is associated with watch by name if need be
res = client.get(
url_for("watch", uuid=watch_uuid),
@ -112,6 +117,21 @@ def test_api_tags_listing(client, live_server, measure_memory_usage):
assert res.status_code == 200
assert new_tag_uuid in res.json.get('tags', [])
# Check recheck by tag
before_check_time = live_server.app.config['DATASTORE'].data['watching'][watch_uuid].get('last_checked')
time.sleep(1)
res = client.get(
url_for("tag", uuid=new_tag_uuid) + "?recheck=true",
headers={'x-api-key': api_key}
)
wait_for_all_checks()
assert res.status_code == 200
assert b'OK, 1 watches' in res.data
after_check_time = live_server.app.config['DATASTORE'].data['watching'][watch_uuid].get('last_checked')
assert before_check_time != after_check_time
# Delete tag
res = client.delete(
url_for("tag", uuid=new_tag_uuid),
@ -141,3 +161,6 @@ def test_api_tags_listing(client, live_server, measure_memory_usage):
headers={'x-api-key': api_key},
)
assert res.status_code == 204