Don’t do multiple get API calls when revoking

It’s redundant to make two API calls here, one to get all keys and one
to get a single key. Since the API calls are sequential we can speed
things up by getting the one key from the list of all keys.
This commit is contained in:
Chris Hill-Scott
2018-11-07 11:53:29 +00:00
parent d1c9dcfb1d
commit 591bbe9a49
5 changed files with 33 additions and 19 deletions

View File

@@ -1639,10 +1639,12 @@ def mock_revoke_api_key(mocker):
@pytest.fixture(scope='function')
def mock_get_api_keys(mocker):
def mock_get_api_keys(mocker, fake_uuid):
def _get_keys(service_id, key_id=None):
keys = {'apiKeys': [api_key_json(service_id, 'some key name'),
api_key_json(service_id, 'another key name', expiry_date=str(date.fromtimestamp(0)))]}
keys = {'apiKeys': [
api_key_json(id_=fake_uuid, name='some key name',),
api_key_json(id_='1234567', name='another key name', expiry_date=str(date.fromtimestamp(0)))
]}
return keys
return mocker.patch('app.api_key_api_client.get_api_keys', side_effect=_get_keys)