mirror of
https://github.com/clearml/clearml-server
synced 2025-04-22 15:16:11 +00:00
Fix internal error returned to clients
This commit is contained in:
parent
c6f1beafdd
commit
3695f25a5f
@ -8,6 +8,7 @@ import jsonmodels.models
|
|||||||
|
|
||||||
from apiserver.apierrors import APIError, errors
|
from apiserver.apierrors import APIError, errors
|
||||||
from apiserver.config_repo import config
|
from apiserver.config_repo import config
|
||||||
|
from apiserver.database.errors import translate_errors_context
|
||||||
from apiserver.utilities.partial_version import PartialVersion
|
from apiserver.utilities.partial_version import PartialVersion
|
||||||
from .apicall import APICall
|
from .apicall import APICall
|
||||||
from .auth import Identity
|
from .auth import Identity
|
||||||
@ -283,6 +284,7 @@ class ServiceRepo(object):
|
|||||||
# In case call does not require authorization, parsing the identity.company might raise an exception
|
# In case call does not require authorization, parsing the identity.company might raise an exception
|
||||||
company = cls._get_company(call, endpoint)
|
company = cls._get_company(call, endpoint)
|
||||||
|
|
||||||
|
with translate_errors_context():
|
||||||
ret = endpoint.func(call, company, call.data_model)
|
ret = endpoint.func(call, company, call.data_model)
|
||||||
|
|
||||||
# allow endpoints to return dict or model (instead of setting them explicitly on the call)
|
# allow endpoints to return dict or model (instead of setting them explicitly on the call)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from apiserver.apierrors.errors.bad_request import InvalidProjectId
|
from apiserver.apierrors.errors.bad_request import InvalidProjectId, ExpectedUniqueData
|
||||||
from apiserver.apierrors.errors.forbidden import NoWritePermission
|
from apiserver.apierrors.errors.forbidden import NoWritePermission
|
||||||
from apiserver.config_repo import config
|
from apiserver.config_repo import config
|
||||||
from apiserver.tests.automated import TestService
|
from apiserver.tests.automated import TestService
|
||||||
@ -32,3 +32,12 @@ class TestProjectsEdit(TestService):
|
|||||||
res = self.api.projects.get_all(id=[p1])
|
res = self.api.projects.get_all(id=[p1])
|
||||||
self.assertEqual([p.id for p in res.projects], [p1])
|
self.assertEqual([p.id for p in res.projects], [p1])
|
||||||
self.api.projects.update(project=p1, name="Test public change 2")
|
self.api.projects.update(project=p1, name="Test public change 2")
|
||||||
|
|
||||||
|
def test_project_name_uniqueness(self):
|
||||||
|
name1 = "Test name1"
|
||||||
|
p1 = self.create_temp("projects", name=name1, description="test")
|
||||||
|
with self.api.raises(ExpectedUniqueData):
|
||||||
|
p2 = self.create_temp("projects", name=name1, description="test")
|
||||||
|
p2 = self.create_temp("projects", name="Test name2", description="test")
|
||||||
|
with self.api.raises(ExpectedUniqueData):
|
||||||
|
self.api.projects.update(project=p2, name=name1)
|
||||||
|
Loading…
Reference in New Issue
Block a user