diff --git a/tests/conftest.py b/tests/conftest.py index 0f4240ef..dc43bb6f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -125,7 +125,10 @@ def file(name: str) -> dict: def tag_id(app: Devicehub) -> str: """Creates a tag and returns its id.""" with app.app_context(): - user = User.query.one() + if User.query.count(): + user = User.query.one() + else: + user = create_user() t = Tag(id='foo', owner_id=user.id) db.session.add(t) db.session.commit() diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 3e63dbf6..5c302c00 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -5,7 +5,7 @@ from uuid import uuid4 import pytest from boltons import urlutils -from teal.db import UniqueViolation +from teal.db import UniqueViolation, DBError from teal.marshmallow import ValidationError from ereuse_devicehub.client import UserClient @@ -274,7 +274,7 @@ def test_snapshot_mismatch_id(): @pytest.mark.mvp -def test_snapshot_tag_inner_tag(tag_id: str, user: UserClient, app: Devicehub): +def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub): """Tests a posting Snapshot with a local tag.""" b = file('basic.snapshot') b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}] @@ -322,7 +322,7 @@ def test_snapshot_different_properties_same_tags(user: UserClient, tag_id: str): def test_snapshot_upload_twice_uuid_error(user: UserClient): pc1 = file('basic.snapshot') user.post(pc1, res=Snapshot) - user.post(pc1, res=Snapshot, status=UniqueViolation) + user.post(pc1, res=Snapshot, status=DBError) @pytest.mark.mvp