mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -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:
@@ -210,7 +210,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(
|
||||
@@ -218,7 +218,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',
|
||||
)
|
||||
mock_model = mocker.patch(
|
||||
'app.models.user.User.__init__',
|
||||
@@ -262,7 +262,7 @@ def test_deletes_user_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)
|
||||
|
||||
Reference in New Issue
Block a user