Add unit tests for gun calculation

This commit is contained in:
Evan Cordell 2017-04-12 14:43:19 -04:00
parent 70ae34357f
commit 883692345b
2 changed files with 17 additions and 1 deletions

View file

@ -33,6 +33,21 @@ valid_response = {
]
}
@pytest.mark.parametrize('tuf_prefix,server_hostname,namespace,repo,gun', [
("quay.dev", "quay.io", "ns", "repo", "quay.dev/ns/repo"),
(None, "quay.io", "ns", "repo", "quay.io/ns/repo"),
("quay.dev/", "quay.io", "ns", "repo", "quay.dev/ns/repo"),
(None, "quay.io/", "ns", "repo", "quay.io/ns/repo"),
(None, "localhost:5000/", "ns", "repo", "localhost:5000/ns/repo"),
(None, "localhost:5000", "ns", "repo", "localhost:5000/ns/repo"),
])
def test_gun(tuf_prefix, server_hostname, namespace, repo, gun):
app = Flask(__name__)
app.config.from_object(testconfig.TestConfig())
app.config['TUF_GUN_PREFIX'] = tuf_prefix
app.config['SERVER_HOSTNAME'] = server_hostname
tuf_api = api.TUFMetadataAPI(app, app.config)
assert gun == tuf_api._gun(namespace, repo)
@pytest.mark.parametrize('response_code,response_body,expected', [
(200, valid_response, (valid_response['signed']['targets'], '2020-03-30T18:55:26.594764859-04:00')),