complet test for basic manual merge
This commit is contained in:
parent
889ee84f6a
commit
0106728e4f
|
@ -13,19 +13,37 @@ from tests.conftest import file as import_snap
|
|||
|
||||
@pytest.mark.mvp
|
||||
def test_simple_merge(app: Devicehub, user: UserClient):
|
||||
snapshot1, _ = user.post(import_snap('basic.snapshot'), res=m.Snapshot)
|
||||
snapshot2, _ = user.post(import_snap('real-eee-1001pxd.snapshot.12'), res=m.Snapshot)
|
||||
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']
|
||||
pc2_id = snapshot2['device']['id']
|
||||
|
||||
# import pdb; pdb.set_trace()
|
||||
with app.app_context():
|
||||
pc1_1 = d.Device.query.filter_by(id=snapshot1['device']['id']).one()
|
||||
pc2_1 = d.Device.query.filter_by(id=snapshot2['device']['id']).one()
|
||||
|
||||
result, _ = user.post({'id': 1}, uri='/devices/%d/merge/%d' % (pc1_id, pc2_id), status=201)
|
||||
pc1 = d.Device.query.filter_by(id=pc1_id).one()
|
||||
pc2 = d.Device.query.filter_by(id=pc2_id).one()
|
||||
n_actions1 = len(pc1.actions)
|
||||
n_actions2 = len(pc2.actions)
|
||||
action1 = pc1.actions[0]
|
||||
action2 = pc2.actions[0]
|
||||
assert not action2 in pc1.actions
|
||||
|
||||
pc1_2 = d.Device.query.filter_by(id=snapshot1['device']['id']).one()
|
||||
pc2_2 = d.Device.query.filter_by(id=snapshot2['device']['id']).one()
|
||||
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
|
||||
|
||||
uri = '/devices/%d/merge/%d' % (pc1_id, pc2_id)
|
||||
result, _ = user.post({'id': 1}, uri=uri, status=201)
|
||||
|
||||
assert pc1.hid == pc2.hid
|
||||
assert action1 in pc1.actions
|
||||
assert action2 in pc1.actions
|
||||
assert len(pc1.actions) == n_actions1 + n_actions2
|
||||
assert set(pc2.components) == set()
|
||||
|
||||
for com in components2:
|
||||
assert com in pc1.components
|
||||
|
||||
for com in components1_excluded:
|
||||
assert not com in pc1.components
|
||||
|
||||
|
|
Reference in a new issue