mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Stop using platform_admin_client fixture
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 For most tests of a platform admin view we used `platform_admin_client` instead. This is not as good because it returns a raw `Response` object and doesn’t do the additional checks. This commit converts all the tests using `platform_admin_client` to: use new `client_request` and log in as `platform_admin_user` before making any requests. This is also nice because it makes any test easy to parametrize with additional users, for example to test differences in behaviour dependant on being platform admin or not.
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from flask import url_for
|
||||
|
||||
sample_inbound_sms = {'data': [{"id": "activated",
|
||||
"number": "0784121212",
|
||||
"provider": "provider_one",
|
||||
@@ -25,10 +22,12 @@ sample_inbound_sms = {'data': [{"id": "activated",
|
||||
]}
|
||||
|
||||
|
||||
def test_inbound_sms_admin(platform_admin_client, mocker):
|
||||
def test_inbound_sms_admin(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mocker,
|
||||
):
|
||||
mocker.patch("app.inbound_number_client.get_all_inbound_sms_number_service", return_value=sample_inbound_sms)
|
||||
response = platform_admin_client.get(url_for("main.inbound_sms_admin"))
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get("main.inbound_sms_admin")
|
||||
assert page.h1.string.strip() == "Inbound SMS"
|
||||
|
||||
Reference in New Issue
Block a user