From 74d10e1951b46c959586e1d1df8480edbd684f1b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Nov 2022 17:49:01 +0100 Subject: [PATCH] add test --- tests/test_snapshot.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index a4753943..fc754ad9 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -1380,3 +1380,27 @@ def test_system_uuid_motherboard(user: UserClient): snap2, _ = user.post(s, res=Snapshot, status=422) txt = "We have detected that a there is a device in your inventory" assert txt in snap2['message'][0] + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_bug_4028_components(user: UserClient): + """Tests when we have one computer and then we change the disk, then + the new disk need to have placeholder too.""" + s = yaml2json('real-eee-1001pxd.snapshot.12') + snap1, _ = user.post(s, res=Snapshot) + dev1 = m.Device.query.filter_by(id=snap1['device']['id']).one() + components1 = [c for c in dev1.components] + for c in s['components']: + if c['type'] == 'HardDrive': + c['serialNumber'] = 'E2024242CV86MF' + + s['uuid'] = str(uuid4()) + snap2, _ = user.post(s, res=Snapshot) + dev2 = m.Device.query.filter_by(id=snap2['device']['id']).one() + components2 = [c for c in dev2.components] + + # import pdb; pdb.set_trace() + + assert '' not in [c.phid() for c in components1] + assert '' not in [c.phid() for c in components2] \ No newline at end of file