From 81acba47003a3c0c1182ad15498685f398c21a8e Mon Sep 17 00:00:00 2001 From: Jonathan Berglind Date: Tue, 13 Feb 2018 15:01:45 +0100 Subject: [PATCH] Use HTTPStatus for existing tests, add more ones Add tests for endpoints being refactored --- tests/end2end/fixtures/test_webserver.py | 36 +++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/end2end/fixtures/test_webserver.py b/tests/end2end/fixtures/test_webserver.py index a59d425e2..8187e32cd 100644 --- a/tests/end2end/fixtures/test_webserver.py +++ b/tests/end2end/fixtures/test_webserver.py @@ -22,6 +22,7 @@ import json import urllib.request import urllib.error +from http import HTTPStatus import pytest @@ -52,11 +53,38 @@ def test_server(server, qtbot, path, content, expected): @pytest.mark.parametrize('line, verb, path, equal', [ - ({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/', True), - ({'verb': 'GET', 'path': '/foo/', 'status': 200}, 'GET', '/foo', True), + ({'verb': 'GET', 'path': '/', 'status': HTTPStatus.OK}, 'GET', '/', True), + ({'verb': 'GET', 'path': '/foo/', 'status': HTTPStatus.OK}, + 'GET', '/foo', True), + ({'verb': 'GET', 'path': '/relative-redirect', 'status': HTTPStatus.FOUND}, + 'GET', '/relative-redirect', True), + ({'verb': 'GET', 'path': '/absolute-redirect', 'status': HTTPStatus.FOUND}, + 'GET', '/absolute-redirect', True), + ({'verb': 'GET', 'path': '/redirect-to', 'status': HTTPStatus.FOUND}, + 'GET', '/redirect-to', True), + ({'verb': 'GET', 'path': '/redirect-self', 'status': HTTPStatus.FOUND}, + 'GET', '/redirect-self', True), + ({'verb': 'GET', 'path': '/content-size', 'status': HTTPStatus.OK}, + 'GET', '/content-size', True), + ({'verb': 'GET', 'path': '/twenty-mb', 'status': HTTPStatus.OK}, + 'GET', '/twenty-mb', True), + ({'verb': 'GET', 'path': '/500-inline', + 'status': HTTPStatus.INTERNAL_SERVER_ERROR}, 'GET', '/500-inline', True), + ({'verb': 'GET', 'path': '/basic-auth/user1/password1', + 'status': HTTPStatus.UNAUTHORIZED}, + 'GET', '/basic-auth/user1/password1', True), + ({'verb': 'GET', 'path': '/drip', 'status': HTTPStatus.OK}, + 'GET', '/drip', True), + ({'verb': 'GET', 'path': '/404', 'status': HTTPStatus.NOT_FOUND}, + 'GET', '/404', True), - ({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/foo', False), - ({'verb': 'POST', 'path': '/', 'status': 200}, 'GET', '/', False), + ({'verb': 'GET', 'path': '/', 'status': HTTPStatus.OK}, + 'GET', '/foo', False), + ({'verb': 'POST', 'path': '/', 'status': HTTPStatus.OK}, + 'GET', '/', False), + ({'verb': 'GET', 'path': '/basic-auth/user/password', + 'status': HTTPStatus.UNAUTHORIZED}, + 'GET', '/basic-auth/user/passwd', False), ]) def test_expected_request(server, line, verb, path, equal): expected = server.ExpectedRequest(verb, path)