X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Futils.py;h=2a919a31dbb057f4db558861d2fafe8277db5521;hb=e14580b4ee47363cad317e4ec1de91affe03d53a;hp=63b07e93e6f14ca51426e2fc00e959fdbfca7bf1;hpb=ac5a85f6d0186d714415ce7e2b51597bf5dca248;p=plomtask diff --git a/tests/utils.py b/tests/utils.py index 63b07e9..2a919a3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -63,13 +63,15 @@ class TestCaseWithServer(TestCaseWithDB): self.assertEqual(self.conn.getresponse().status, expected_code) def check_post(self, data: Mapping[str, object], target: str, - expected_code: int, redirect_location: str = '/') -> None: + expected_code: int, redirect_location: str = '') -> None: """Check that POST of data to target yields expected_code.""" encoded_form_data = urlencode(data, doseq=True).encode('utf-8') headers = {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': str(len(encoded_form_data))} self.conn.request('POST', target, body=encoded_form_data, headers=headers) + if redirect_location == '': + redirect_location = target if 302 == expected_code: self.check_redirect(redirect_location) else: