diff --git a/tests/files/basic.snapshot.nohid.yaml b/tests/files/basic.snapshot.nohid.yaml new file mode 100644 index 00000000..f6b1f0c0 --- /dev/null +++ b/tests/files/basic.snapshot.nohid.yaml @@ -0,0 +1,30 @@ +type: Snapshot +uuid: 9a3e7485-fdd0-47ce-bcc7-65c55226b598 +version: '11.0b9' +software: Workbench +elapsed: 4 +device: + type: Desktop + chassis: Microtower + serialNumber: null + model: null + manufacturer: null + actions: + - type: VisualTest + appearanceRange: A + functionalityRange: B +components: + - type: RamModule + serialNumber: rm1s + model: rm1ml + manufacturer: rm1mr + speed: 1333 + - type: Processor + serialNumber: p1s + model: p1ml + manufacturer: p1mr + speed: 1.6 + actions: + - type: BenchmarkProcessor + rate: 2410 + elapsed: 11 diff --git a/tests/test_basic.py b/tests/test_basic.py index 25167c6a..e9566c0d 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -32,7 +32,8 @@ def test_api_docs(client: Client): '/documents/static/{filename}', '/tags/{tag_id}/device/{device_id}', '/devices/static/{filename}', - '/deliverynotes/' + '/deliverynotes/', + '/proofs/' } assert docs['info'] == {'title': 'Devicehub', 'version': '0.2'} assert docs['components']['securitySchemes']['bearerAuth'] == { @@ -43,4 +44,4 @@ def test_api_docs(client: Client): 'scheme': 'basic', 'name': 'Authorization' } - assert len(docs['definitions']) == 116 + assert len(docs['definitions']) == 122 diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index c3c211d7..098e0c5f 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -229,6 +229,28 @@ def _test_snapshot_computer_no_hid(user: UserClient): user.post(s, res=Snapshot) +def test_snapshot_post_without_hid(user: UserClient): + """Tests the post snapshot endpoint (validation, etc), data correctness, + and relationship correctness with HID field generated with type - model - manufacturer - S/N. + """ + snapshot = snapshot_and_check(user, file('basic.snapshot.nohid'), + action_types=( + BenchmarkProcessor.t, + VisualTest.t, + RateComputer.t + ), + perform_second_snapshot=False) + assert snapshot['software'] == 'Workbench' + assert snapshot['version'] == '11.0b9' + assert snapshot['uuid'] == '9a3e7485-fdd0-47ce-bcc7-65c55226b598' + assert snapshot['elapsed'] == 4 + assert snapshot['author']['id'] == user.user['id'] + assert 'actions' not in snapshot['device'] + assert 'author' not in snapshot['device'] + response = user.post(snapshot, res=Snapshot) + assert response.status == 201 + + def test_snapshot_mismatch_id(): """Tests uploading a device with an ID from another device.""" # Note that this won't happen as in this new version @@ -417,7 +439,8 @@ def assert_similar_device(device1: dict, device2: dict): assert isinstance(device1, dict) and device1 assert isinstance(device2, dict) and device2 for key in 'serialNumber', 'model', 'manufacturer', 'type': - assert device1.get(key, '').lower() == device2.get(key, '').lower() + if (device1.get(key, '') is not None) and (device2.get(key, '') is not None): + assert device1.get(key, '').lower() == device2.get(key, '').lower() def assert_similar_components(components1: List[dict], components2: List[dict]):