bug for moving tags

This commit is contained in:
Cayo Puigdefabregas 2020-10-28 22:15:04 +01:00
parent 3af8880bcd
commit 5717743d2f
1 changed files with 11 additions and 0 deletions

View File

@ -4,15 +4,18 @@ from flask import g
import pytest
from ereuse_devicehub.client import Client, UserClient
from ereuse_devicehub.db import db
from ereuse_devicehub.devicehub import Devicehub
from ereuse_devicehub.resources.action import models as m
from ereuse_devicehub.resources.device import models as d
from ereuse_devicehub.resources.tag import Tag
from tests import conftest
from tests.conftest import file as import_snap
@pytest.mark.mvp
def test_simple_merge(app: Devicehub, user: UserClient):
""" Check if is correct to do a manual merge """
snapshot1, _ = user.post(import_snap('real-custom.snapshot.11'), res=m.Snapshot)
snapshot2, _ = user.post(import_snap('real-hp.snapshot.11'), res=m.Snapshot)
pc1_id = snapshot1['device']['id']
@ -27,10 +30,16 @@ def test_simple_merge(app: Devicehub, user: UserClient):
action2 = pc2.actions[0]
assert not action2 in pc1.actions
tag = Tag(id='foo-bar', owner_id=user.user['id'])
pc2.tags.add(tag)
db.session.add(pc2)
db.session.commit()
components1 = [com for com in pc1.components]
components2 = [com for com in pc2.components]
components1_excluded = [com for com in pc1.components if not com in components2]
assert pc1.hid != pc2.hid
assert not tag in pc1.tags
uri = '/devices/%d/merge/%d' % (pc1_id, pc2_id)
result, _ = user.post({'id': 1}, uri=uri, status=201)
@ -40,6 +49,8 @@ def test_simple_merge(app: Devicehub, user: UserClient):
assert action2 in pc1.actions
assert len(pc1.actions) == n_actions1 + n_actions2
assert set(pc2.components) == set()
assert tag in pc1.tags
assert not tag in pc2.tags
for com in components2:
assert com in pc1.components