bugfix: user before tag_id

This commit is contained in:
Cayo Puigdefabregas 2020-07-23 07:56:51 +02:00
parent 46b985e222
commit 08b2fe90d0
2 changed files with 7 additions and 4 deletions

View file

@ -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()

View file

@ -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