From 8c10b0787df0cbd25859649981045139b58932ea Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 4 Apr 2017 13:57:24 -0400 Subject: [PATCH] Change appr error if you try to push to an image repository 501 was confusing to the users, so change to 405 and add an error explaining why the push failed Fixes https://github.com/app-registry/helm-plugin/issues/8#issuecomment-291553739 --- endpoints/appr/decorators.py | 6 +++--- endpoints/appr/test/test_appr_decorators.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/endpoints/appr/decorators.py b/endpoints/appr/decorators.py index 5d6e78589..2de588055 100644 --- a/endpoints/appr/decorators.py +++ b/endpoints/appr/decorators.py @@ -2,10 +2,10 @@ import logging from functools import wraps -from flask import abort - from data import model +from util.http import abort + logger = logging.getLogger(__name__) @@ -26,7 +26,7 @@ def disallow_for_image_repository(get_reponame_method=_get_reponame_kwargs): image_repo = model.repository.get_repository(namespace_name, repo_name, kind_filter='image') if image_repo is not None: logger.debug('Tried to invoked a CNR method on an image repository') - abort(501) + abort(405, message='Cannot push an application to an image repository with the same name') return func(*args, **kwargs) return wrapped return wrapper diff --git a/endpoints/appr/test/test_appr_decorators.py b/endpoints/appr/test/test_appr_decorators.py index fee7ea7cb..c71b3107c 100644 --- a/endpoints/appr/test/test_appr_decorators.py +++ b/endpoints/appr/test/test_appr_decorators.py @@ -1,6 +1,6 @@ import pytest -from werkzeug.exceptions import NotImplemented as NIE +from werkzeug.exceptions import HTTPException from data import model from endpoints.appr import require_app_repo_read @@ -14,6 +14,6 @@ def test_require_app_repo_read(app): def empty(**kwargs): called[0] = True - with pytest.raises(NIE): + with pytest.raises(HTTPException): empty(namespace='devtable', package_name='simple') assert not called[0]