mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
move (non-api) clients (inc redis) from app/__init__.py to extensions
when clients are defined in app/__init__.py, it increases the chance of cyclical imports. By moving module level client singletons out to a separate extensions file, we stop cyclical imports, but keep the same code flow - the clients are still initialised in `create_app` in `__init__.py`. The redis client in particular is no longer separate - previously redis was set up on the `NotifyAdminAPIClient` base class, but now there's one singleton in `app.extensions`. This was done so that we can access redis from outside of the existing clients.
This commit is contained in:
@@ -324,7 +324,7 @@ def test_returns_value_from_cache(
|
||||
):
|
||||
|
||||
mock_redis_get = mocker.patch(
|
||||
'app.notify_client.RedisClient.get',
|
||||
'app.extensions.RedisClient.get',
|
||||
return_value=cache_value,
|
||||
)
|
||||
mock_api_get = mocker.patch(
|
||||
@@ -332,7 +332,7 @@ def test_returns_value_from_cache(
|
||||
return_value={'data_from': 'api'},
|
||||
)
|
||||
mock_redis_set = mocker.patch(
|
||||
'app.notify_client.RedisClient.set',
|
||||
'app.extensions.RedisClient.set',
|
||||
)
|
||||
|
||||
assert client_method(*extra_args) == expected_return_value
|
||||
@@ -375,7 +375,7 @@ def test_deletes_service_cache(
|
||||
extra_kwargs,
|
||||
):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
mock_redis_delete = mocker.patch('app.notify_client.RedisClient.delete')
|
||||
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
|
||||
mock_request = mocker.patch('notifications_python_client.base.BaseAPIClient.request')
|
||||
|
||||
getattr(client, method)(*extra_args, **extra_kwargs)
|
||||
@@ -423,7 +423,7 @@ def test_deletes_caches_when_modifying_templates(
|
||||
expected_cache_deletes,
|
||||
):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
mock_redis_delete = mocker.patch('app.notify_client.RedisClient.delete')
|
||||
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
|
||||
mock_request = mocker.patch('notifications_python_client.base.BaseAPIClient.request')
|
||||
|
||||
getattr(service_api_client, method)(*extra_args)
|
||||
|
||||
Reference in New Issue
Block a user