mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Replace instances of client.login with client_request
We have a `client_request` fixture which does a bunch of useful stuff
like:
- checking the status code of the response
- returning a `BeautifulSoup` object
Lots of our tests still use an older fixture called `client`. This is
not as good because it:
- returns a raw `Response` object
- doesn’t do the additional checks
- means our tests contain a lot of repetetive boilerplate like `page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')`
This commit converts all the tests which had a `client.login(…)`
statement to use `client_request` (which is already logged in by
default).
Subsequent commits will remove uses of `client` in other tests, but
doing it this way means the work can be broken up into more manageable
chunks.
This commit is contained in:
@@ -171,21 +171,19 @@ def test_api_documentation_page_should_redirect(
|
||||
|
||||
|
||||
def test_should_show_empty_api_keys_page(
|
||||
client,
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_no_api_keys,
|
||||
mock_get_service,
|
||||
mock_has_permissions,
|
||||
):
|
||||
client.login(api_user_active)
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for('main.api_keys', service_id=service_id))
|
||||
client_request.login(api_user_active)
|
||||
page = client_request.get('main.api_keys', service_id=SERVICE_ONE_ID)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'You have not created any API keys yet' in response.get_data(as_text=True)
|
||||
assert 'Create an API key' in response.get_data(as_text=True)
|
||||
mock_get_no_api_keys.assert_called_once_with(service_id)
|
||||
assert 'You have not created any API keys yet' in page.text
|
||||
assert 'Create an API key' in page.text
|
||||
mock_get_no_api_keys.assert_called_once_with(SERVICE_ONE_ID)
|
||||
|
||||
|
||||
def test_should_show_api_keys_page(
|
||||
|
||||
Reference in New Issue
Block a user