mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -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:
@@ -10,7 +10,7 @@ def test_client_creates_job_data_correctly(mocker, fake_uuid):
|
||||
job_id = fake_uuid
|
||||
service_id = fake_uuid
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
mock_redis_set = mocker.patch('app.notify_client.RedisClient.set')
|
||||
mock_redis_set = mocker.patch('app.extensions.RedisClient.set')
|
||||
|
||||
expected_data = {
|
||||
"id": job_id,
|
||||
@@ -330,7 +330,7 @@ def test_has_jobs_sets_cache(
|
||||
'app.notify_client.job_api_client.JobApiClient.get',
|
||||
return_value={'data': job_data}
|
||||
)
|
||||
mock_redis_set = mocker.patch('app.notify_client.RedisClient.set')
|
||||
mock_redis_set = mocker.patch('app.extensions.RedisClient.set')
|
||||
|
||||
JobApiClient().has_jobs(fake_uuid)
|
||||
|
||||
@@ -359,7 +359,7 @@ def test_has_jobs_returns_from_cache(
|
||||
'app.notify_client.job_api_client.JobApiClient.get'
|
||||
)
|
||||
mock_redis_get = mocker.patch(
|
||||
'app.notify_client.RedisClient.get',
|
||||
'app.extensions.RedisClient.get',
|
||||
return_value=cache_value,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user