bugfix: DBError insted of UniqueViolation in raise check

This commit is contained in:
Cayo Puigdefabregas 2020-07-22 15:41:04 +02:00
parent b01c241685
commit dc24599075
1 changed files with 3 additions and 2 deletions

View File

@ -5,7 +5,7 @@ import requests_mock
from boltons.urlutils import URL
from ereuse_utils.session import DevicehubClient
from pytest import raises
from teal.db import MultipleResourcesFound, ResourceNotFound, UniqueViolation
from teal.db import MultipleResourcesFound, ResourceNotFound, UniqueViolation, DBError
from teal.marshmallow import ValidationError
from ereuse_devicehub.client import UserClient
@ -67,7 +67,8 @@ def test_create_two_same_tags(user: UserClient):
db.session.add(Tag(id='foo-bar', owner_id=user.user['id']))
db.session.add(Tag(id='foo-bar', owner_id=user.user['id']))
with raises(UniqueViolation):
with raises(DBError):
db.session.commit()
db.session.rollback()
# And it works if tags are in different organizations