From e92dab525968f77b28bf68e36f95e5893a75e3ce Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sun, 5 Feb 2023 19:32:23 +0100 Subject: [PATCH] Also test for 204 - with empty reply --- changedetectionio/tests/test_backend.py | 4 ++-- changedetectionio/tests/util.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index 03d5f475..79be0278 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -20,7 +20,7 @@ def test_setup(client, live_server): # Assert that non-200's dont give notifications or register as a change def test_non_200_doesnt_trigger_change(client, live_server): - # live_server_setup(live_server) + # live_server_setup(live_server) set_original_response() url = url_for('test_changing_status_code_endpoint', _external=True) @@ -58,7 +58,7 @@ def test_non_200_doesnt_trigger_change(client, live_server): set_modified_response() # https://github.com/dgtlmoon/changedetection.io/issues/962#issuecomment-1416807742 - for ecode in ['429', '400', '429', '403', '404', '500']: + for ecode in ['429', '400', '204', '429', '403', '404', '500']: with open("test-endpoint-status-code.txt", 'w') as f: f.write(ecode) diff --git a/changedetectionio/tests/util.py b/changedetectionio/tests/util.py index 8319ea7c..cab04d89 100644 --- a/changedetectionio/tests/util.py +++ b/changedetectionio/tests/util.py @@ -127,6 +127,8 @@ def live_server_setup(live_server): # (Non-200 should get ignored) with open("test-datastore/endpoint-content.txt", "r") as f: contents ="{} code: {} ".format(f.read(), status_code) + if status_code == '204': + contents='' resp = make_response(contents, status_code) resp.headers['Content-Type'] = 'text/html' return resp, status_code