mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-13 23:14:32 -05:00
Make client_request understand POST-redirect-GET
When we do a `POST` we almost always do a redirect straight afterwards. `client_request` understands this, and expects a `302` by default. However, if the `_follow_redirects` flag is set the status code returned is that of the subsequent request – normally a `GET`, itself returning `200`. Therefore the default expected response code would need to be overridden. Overriding this repeatedly would get pretty boring. Better to do it once inside the fixture.
This commit is contained in:
@@ -1716,7 +1716,9 @@ def client_request(logged_in_client):
|
||||
return BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
|
||||
|
||||
@staticmethod
|
||||
def post(endpoint, _data=None, _expected_status=302, _follow_redirects=False, **endpoint_kwargs):
|
||||
def post(endpoint, _data=None, _expected_status=None, _follow_redirects=False, **endpoint_kwargs):
|
||||
if _expected_status is None:
|
||||
_expected_status = 200 if _follow_redirects else 302
|
||||
resp = logged_in_client.post(
|
||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||
data=_data,
|
||||
|
||||
Reference in New Issue
Block a user