mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-04 21:51:43 -04:00
Mark client fixture as ‘private’
No tests are now using the `client` fixture directly so we can rename it. Python convention is to use an `_underscore` for things which should be considered semi private. This should discourage people from writing new tests with these old fixtures. New tests should always use `client_request`. Want to be logged in with a different user? Call `client_request.login(user)` first. Don’t want to be logged in? Call `client_request.logout()` first (most of our tests need to be logged in). Need an instance of `Response` object not an instance of `BeautifulSoup`? Use `client_request.get_response` or `client_request.post_response`. Need to pass in a URL, not arguments to `url_for`? Use `client_request.get_url(…)` or `client_request.post_url(…)`. Need to pass in a URL and get a response back? Use `client_request.get_response_from_url(…)` or `client_request.post_response_from_url(…)`.
This commit is contained in:
@@ -2732,21 +2732,27 @@ def mock_send_notification(mocker, fake_uuid):
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def client(notify_admin):
|
||||
def _client(notify_admin):
|
||||
"""
|
||||
Do not use this fixture directly – use `client_request` instead
|
||||
"""
|
||||
with notify_admin.test_request_context(), notify_admin.test_client() as client:
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def _logged_in_client(
|
||||
client,
|
||||
_client,
|
||||
active_user_with_permissions,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_login
|
||||
):
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
yield client
|
||||
"""
|
||||
Do not use this fixture directly – use `client_request` instead
|
||||
"""
|
||||
_client.login(active_user_with_permissions, mocker, service_one)
|
||||
yield _client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user