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',
self.conn.request('POST', target,
body=encoded_form_data, headers=headers)
if 302 == expected_code:
+ if redirect_location == '':
+ redirect_location = target
self.check_redirect(redirect_location)
else:
self.assertEqual(self.conn.getresponse().status, expected_code)