mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Change client_request so its kwargs look more like url_for
This commit is contained in:
@@ -96,6 +96,7 @@ class Development(Config):
|
|||||||
|
|
||||||
class Test(Development):
|
class Test(Development):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
TESTING = True
|
||||||
STATSD_ENABLED = True
|
STATSD_ENABLED = True
|
||||||
WTF_CSRF_ENABLED = False
|
WTF_CSRF_ENABLED = False
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
||||||
|
|||||||
@@ -55,5 +55,5 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
|||||||
params=params
|
params=params
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_notification(self, service_id, notification_id):m
|
def get_notification(self, service_id, notification_id):
|
||||||
return self.get(url='/service/{}/notifications/{}'.format(service_id, notification_id))
|
return self.get(url='/service/{}/notifications/{}'.format(service_id, notification_id))
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ def test_notification_status_page_shows_details(
|
|||||||
):
|
):
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notification',
|
'main.view_notification',
|
||||||
endpoint_kwargs={
|
service_id=service_one['id'],
|
||||||
'service_id': service_one['id'],
|
notification_id=fake_uuid
|
||||||
'notification_id': fake_uuid
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert page.find('div', {'class': 'sms-message-wrapper'}).text.strip() == 'service one: template content'
|
assert page.find('div', {'class': 'sms-message-wrapper'}).text.strip() == 'service one: template content'
|
||||||
@@ -72,10 +70,8 @@ def test_notification_status_page_shows_correct_numbers(
|
|||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notification',
|
'main.view_notification',
|
||||||
endpoint_kwargs={
|
service_id=service_one['id'],
|
||||||
'service_id': service_one['id'],
|
notification_id=fake_uuid
|
||||||
'notification_id': fake_uuid
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
big_numbers = page.find_all('div', {'class': 'big-number-number'})
|
big_numbers = page.find_all('div', {'class': 'big-number-number'})
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
@@ -1702,26 +1703,27 @@ def os_environ():
|
|||||||
os.environ = old_env
|
os.environ = old_env
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client_request(logged_in_client):
|
def client_request(logged_in_client):
|
||||||
class ClientRequest:
|
class ClientRequest:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(endpoint, endpoint_kwargs=None, expected_status=200, follow_redirects=False):
|
def get(endpoint, _expected_status=200, _follow_redirects=False, **endpoint_kwargs):
|
||||||
resp = logged_in_client.get(
|
resp = logged_in_client.get(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {}))
|
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||||
|
follow_redirects=_follow_redirects,
|
||||||
)
|
)
|
||||||
assert resp.status_code == expected_status
|
assert resp.status_code == _expected_status
|
||||||
return BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
|
return BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post(endpoint, endpoint_kwargs=None, data=None, expected_status=302, follow_redirects=False):
|
def post(endpoint, _data=None, _expected_status=302, _follow_redirects=False, **endpoint_kwargs):
|
||||||
resp = logged_in_client.post(
|
resp = logged_in_client.post(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||||
data
|
data=_data,
|
||||||
|
follow_redirects=_follow_redirects,
|
||||||
)
|
)
|
||||||
assert resp.status_code == expected_status
|
assert resp.status_code == _expected_status
|
||||||
return BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
|
return BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
|
||||||
|
|
||||||
return ClientRequest
|
return ClientRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user