Also test for 204 - with empty reply

bug-non-200s-triggering
dgtlmoon 2 years ago
parent ec0f134e0e
commit e92dab5259

@ -20,7 +20,7 @@ def test_setup(client, live_server):
# Assert that non-200's dont give notifications or register as a change # Assert that non-200's dont give notifications or register as a change
def test_non_200_doesnt_trigger_change(client, live_server): def test_non_200_doesnt_trigger_change(client, live_server):
# live_server_setup(live_server) # live_server_setup(live_server)
set_original_response() set_original_response()
url = url_for('test_changing_status_code_endpoint', _external=True) 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() set_modified_response()
# https://github.com/dgtlmoon/changedetection.io/issues/962#issuecomment-1416807742 # 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: with open("test-endpoint-status-code.txt", 'w') as f:
f.write(ecode) f.write(ecode)

@ -127,6 +127,8 @@ def live_server_setup(live_server):
# (Non-200 should get ignored) # (Non-200 should get ignored)
with open("test-datastore/endpoint-content.txt", "r") as f: with open("test-datastore/endpoint-content.txt", "r") as f:
contents ="{} code: {} ".format(f.read(), status_code) contents ="{} code: {} ".format(f.read(), status_code)
if status_code == '204':
contents=''
resp = make_response(contents, status_code) resp = make_response(contents, status_code)
resp.headers['Content-Type'] = 'text/html' resp.headers['Content-Type'] = 'text/html'
return resp, status_code return resp, status_code

Loading…
Cancel
Save