From ebe089499d7b51e7980264d022bd890df9c5402a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Apr 2021 13:25:41 +0200 Subject: [PATCH] fixing tests --- tests/test_device_find.py | 10 +++++----- tests/test_tag.py | 2 +- tests/test_workbench.py | 28 ++++++++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/test_device_find.py b/tests/test_device_find.py index 7e9ac291..82716719 100644 --- a/tests/test_device_find.py +++ b/tests/test_device_find.py @@ -176,10 +176,10 @@ def test_device_query_filter_lots(user: UserClient): @pytest.mark.mvp def test_device_query(user: UserClient): """Checks result of inventory.""" - user.post(conftest.file('basic.snapshot'), res=Snapshot) + snapshot, _ = user.post(conftest.file('basic.snapshot'), res=Snapshot) i, _ = user.get(res=Device) assert i['url'] == '/devices/' - assert i['items'][0]['url'] == '/devices/1' + assert i['items'][0]['url'] == '/devices/{}'.format(snapshot['device']['id']) pc = next(d for d in i['items'] if d['type'] == 'Desktop') assert len(pc['actions']) == 4 assert len(pc['components']) == 3 @@ -241,14 +241,14 @@ def test_device_search_regenerate_table(app: DeviceSearch, user: UserClient): @pytest.mark.mvp def test_device_query_search(user: UserClient): # todo improve - user.post(file('basic.snapshot'), res=Snapshot) + snapshot, _ = user.post(file('basic.snapshot'), res=Snapshot) user.post(file('computer-monitor.snapshot'), res=Snapshot) user.post(file('real-eee-1001pxd.snapshot.11'), res=Snapshot) i, _ = user.get(res=Device, query=[('search', 'desktop')]) - assert i['items'][0]['id'] == 1 + assert i['items'][0]['id'] == snapshot['device']['id'] i, _ = user.get(res=Device, query=[('search', 'intel')]) assert len(i['items']) == 1 - i, _ = user.get(res=Device, query=[('search', '1')]) + i, _ = user.get(res=Device, query=[('search', snapshot['device']['id'])]) assert len(i['items']) == 1 diff --git a/tests/test_tag.py b/tests/test_tag.py index f6402bd4..5e8d6648 100644 --- a/tests/test_tag.py +++ b/tests/test_tag.py @@ -282,7 +282,7 @@ def test_tag_manual_link_search(app: Devicehub, user: UserClient): db.session.commit() desktop_id = desktop.id user.put({}, res=Tag, item='foo-bar/device/{}'.format(desktop_id), status=204) - device, _ = user.get(res=Device, item=1) + device, _ = user.get(res=Device, item=desktop_id) assert device['tags'][0]['id'] == 'foo-bar' # Device already linked diff --git a/tests/test_workbench.py b/tests/test_workbench.py index e2d5ce9a..6f453739 100644 --- a/tests/test_workbench.py +++ b/tests/test_workbench.py @@ -32,20 +32,24 @@ def test_workbench_server_condensed(user: UserClient): user.post({'id': t['id']}, res=Tag) snapshot, _ = user.post(res=em.Snapshot, data=s) + pc_id = snapshot['device']['id'] + cpu_id = snapshot['components'][3]['id'] + ssd_id= snapshot['components'][4]['id'] + hdd_id = snapshot['components'][5]['id'] actions = snapshot['actions'] assert {(action['type'], action['device']) for action in actions} == { - ('BenchmarkProcessorSysbench', 5), - ('StressTest', 1), - ('EraseSectors', 6), - ('EreusePrice', 1), - ('BenchmarkRamSysbench', 1), - ('BenchmarkProcessor', 5), - ('Install', 6), - ('EraseSectors', 7), - ('BenchmarkDataStorage', 6), - ('BenchmarkDataStorage', 7), - ('TestDataStorage', 6), - ('RateComputer', 1) + ('BenchmarkProcessorSysbench', cpu_id), + ('StressTest', pc_id), + ('EraseSectors', ssd_id), + ('EreusePrice', pc_id), + ('BenchmarkRamSysbench', pc_id), + ('BenchmarkProcessor', cpu_id), + ('Install', ssd_id), + ('EraseSectors', hdd_id), + ('BenchmarkDataStorage', ssd_id), + ('BenchmarkDataStorage', hdd_id), + ('TestDataStorage', ssd_id), + ('RateComputer', pc_id) } assert snapshot['closed'] assert snapshot['severity'] == 'Info'