Return hashes and expiration when fetching signed tags

This commit is contained in:
Evan Cordell 2017-04-07 16:12:28 -04:00
parent 1a78722521
commit 217b4a5ab2
5 changed files with 42 additions and 44 deletions

View file

@ -35,8 +35,8 @@ valid_response = {
@pytest.mark.parametrize('response_code,response_body,expected', [
(200, valid_response, valid_response['signed']['targets']),
(200, {'garbage': 'data'}, None)
(200, valid_response, (valid_response['signed']['targets'], '2020-03-30T18:55:26.594764859-04:00')),
(200, {'garbage': 'data'}, (None, None))
])
def test_get_metadata(response_code, response_body, expected):
app = Flask(__name__)
@ -46,8 +46,8 @@ def test_get_metadata(response_code, response_body, expected):
request.json.return_value = response_body
client.request.return_value = request
tuf_api = api.TUFMetadataAPI(app, app.config, client=client)
tags, _ = tuf_api.get_default_tags('quay', 'quay')
assert tags == expected
response = tuf_api.get_default_tags_with_expiration('quay', 'quay')
assert response == expected
@pytest.mark.parametrize('connection_error,response_code,exception', [
(True, 200, requests.exceptions.Timeout),
@ -67,5 +67,6 @@ def test_get_metadata_exception(connection_error, response_code, exception):
client = mock.Mock(request=request)
client.request.side_effect = exception
tuf_api = api.TUFMetadataAPI(app, app.config, client=client)
tags, _ = tuf_api.get_default_tags('quay', 'quay')
assert tags == None
tags, expiration = tuf_api.get_default_tags_with_expiration('quay', 'quay')
assert tags == None
assert expiration == None