mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05: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):
|
||||
DEBUG = True
|
||||
TESTING = True
|
||||
STATSD_ENABLED = True
|
||||
WTF_CSRF_ENABLED = False
|
||||
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
||||
|
||||
@@ -55,5 +55,5 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
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))
|
||||
|
||||
@@ -39,10 +39,8 @@ def test_notification_status_page_shows_details(
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
endpoint_kwargs={
|
||||
'service_id': service_one['id'],
|
||||
'notification_id': fake_uuid
|
||||
}
|
||||
service_id=service_one['id'],
|
||||
notification_id=fake_uuid
|
||||
)
|
||||
|
||||
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(
|
||||
'main.view_notification',
|
||||
endpoint_kwargs={
|
||||
'service_id': service_one['id'],
|
||||
'notification_id': fake_uuid
|
||||
}
|
||||
service_id=service_one['id'],
|
||||
notification_id=fake_uuid
|
||||
)
|
||||
|
||||
big_numbers = page.find_all('div', {'class': 'big-number-number'})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import os
|
||||
from datetime import date, datetime, timedelta
|
||||
from unittest.mock import Mock
|
||||
@@ -1702,26 +1703,27 @@ def os_environ():
|
||||
os.environ = old_env
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture
|
||||
def client_request(logged_in_client):
|
||||
class ClientRequest:
|
||||
|
||||
@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(
|
||||
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')
|
||||
|
||||
@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(
|
||||
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 ClientRequest
|
||||
|
||||
Reference in New Issue
Block a user