refactor(api/tag): remove try/catch
This commit is contained in:
parent
eb9db0c53b
commit
6e894d5f24
2 changed files with 14 additions and 18 deletions
|
@ -32,7 +32,7 @@ def create_or_update_tag():
|
|||
@pytest.fixture()
|
||||
def generate_manifest():
|
||||
def mock_callable(namespace, repository, tag):
|
||||
if tag is 'generatemanifestfail':
|
||||
if tag == 'generatemanifestfail':
|
||||
raise Exception('test_failure')
|
||||
with patch('endpoints.api.tag._generate_and_store_manifest', side_effect=mock_callable) as mk:
|
||||
yield mk
|
||||
|
@ -47,11 +47,15 @@ def authd_client(client):
|
|||
('image1', '.INVALID-TAG-NAME', 400),
|
||||
('image1', 'INVALID-TAG_NAME-BECAUSE-THIS-IS-WAY-WAY-TOO-LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG', 400),
|
||||
('nonexistantimage', 'newtag', 404),
|
||||
('image1', 'generatemanifestfail', 201),
|
||||
('image1', 'generatemanifestfail', None),
|
||||
('image1', 'existing-tag', 201),
|
||||
('image1', 'newtag', 201),
|
||||
])
|
||||
def test_move_tag(test_image, test_tag, expected_status, get_repo_image, get_repo_tag_image, create_or_update_tag, generate_manifest, authd_client):
|
||||
params = {'repository': 'devtable/repo', 'tag': test_tag}
|
||||
request_body = {'image': test_image}
|
||||
conduct_api_call(authd_client, RepositoryTag, 'put', params, request_body, expected_status)
|
||||
if expected_status is None:
|
||||
with pytest.raises(Exception):
|
||||
conduct_api_call(authd_client, RepositoryTag, 'put', params, request_body, expected_status)
|
||||
else:
|
||||
conduct_api_call(authd_client, RepositoryTag, 'put', params, request_body, expected_status)
|
||||
|
|
Reference in a new issue