adding new tests of snapshots

This commit is contained in:
Cayo Puigdefabregas 2020-10-14 11:40:33 +02:00
parent d3ef6cc65d
commit 150c73779d
5 changed files with 223 additions and 0 deletions

View File

@ -0,0 +1,36 @@
type: Snapshot
uuid: 62b3e393-0c25-42cf-a5fa-ab796fac76dd
version: 11.0
software: Workbench
elapsed: 4
device:
type: Laptop
chassis: Notebook
serialNumber: d6s
model: d6ml
manufacturer: d6mr
components:
- type: RamModule
serialNumber: rm6s
model: rm6ml
manufacturer: rm6mr
speed: 1333
- type: Processor
serialNumber: p6s
model: p6ml
manufacturer: p6mr
speed: 1.6
actions:
- type: BenchmarkProcessor
rate: 2410
elapsed: 11
- type: HardDrive
size: 160041.88569599998
model: hdd4m
manufacturer: hdd4mr
serialNumber: hdd4s
actions:
- type: BenchmarkDataStorage
elapsed: 22
writeSpeed: 17.3
readSpeed: 41.6

View File

@ -0,0 +1,36 @@
type: Snapshot
uuid: 81e1f340-5aac-4619-931b-d312e4866cb7
version: 11.0
software: Workbench
elapsed: 4
device:
type: Laptop
chassis: null
serialNumber: d5s
model: d5ml
manufacturer: d5mr
components:
- type: RamModule
serialNumber: rm5s
model: rm5ml
manufacturer: rm5mr
speed: 1333
type: Processor
serialNumber: p5s
model: p5ml
manufacturer: p5mr
speed: 1.6
actions:
- type: BenchmarkProcessor
rate: 2410
elapsed: 11
size: 160041.88569599998
model: hdd5m
type: HardDrive
manufacturer: hdd5mr
serialNumber: hdd5s
actions:
- type: BenchmarkDataStorage
elapsed: 22
writeSpeed: 17.3
readSpeed: 41.6

View File

@ -0,0 +1,22 @@
type: Snapshot
uuid: 127fad1c-a3f2-4677-9dab-4a370071a882
version: 11.0
software: Workbench
elapsed: 4
device:
type: Laptop
chassis: Microtower
serialNumber: d2s
model: d2ml
manufacturer: d2mr
components:
- type: RamModule
serialNumber: rm2s
model: rm2ml
manufacturer: rm2mr
speed: 1333
- type: Processor
serialNumber: p2s
model: p2ml
manufacturer: p2mr
speed: 1.6

View File

@ -0,0 +1,31 @@
type: Snapshot
uuid: 2afa5413-9858-4577-8273-a027a647fed0
version: 11.0
software: Workbench
elapsed: 4
device:
type: Desktop
chassis: Microtower
serialNumber: d3s
model: d3ml
manufacturer: d3mr
components:
- type: RamModule
serialNumber: rm3s
model: rm3ml
manufacturer: rm3mr
speed: 1333
- type: Processor
serialNumber: p3s
model: p3ml
manufacturer: p3mr
speed: 1.6
size: 160041.88569599998
model: hdd3m
type: HardDrive
manufacturer: hdd3mr
serialNumber: hdd3s
actions:
- type: BenchmarkProcessor
rate: 2410
elapsed: 11

View File

@ -525,3 +525,101 @@ def test_backup_snapshot_with_errors(app: Devicehub, user: UserClient):
assert snapshot['software'] == snapshot_no_hid['software']
assert snapshot['version'] == snapshot_no_hid['version']
assert snapshot['uuid'] == uuid
@pytest.mark.mvp
def test_snapshot_failed_missing_cpu_benchmark(app: Devicehub, user: UserClient):
""" This test check if the file snapshot is create when some snapshot is wrong """
tmp_snapshots = app.config['TMP_SNAPSHOTS']
snapshot_error = file('failed.snapshot.500.missing-cpu-benchmark')
uuid = snapshot_error['uuid']
snapshot = {'software': '', 'version': '', 'uuid': ''}
with pytest.raises(TypeError):
user.post(res=Snapshot, data=snapshot_error)
files = [x for x in os.listdir(tmp_snapshots) if uuid in x]
if files:
path_snapshot = os.path.join(tmp_snapshots, files[0])
with open(path_snapshot) as file_snapshot:
snapshot = json.loads(file_snapshot.read())
os.remove(path_snapshot)
assert snapshot['software'] == snapshot_error['software']
assert snapshot['version'] == snapshot_error['version']
assert snapshot['uuid'] == uuid
@pytest.mark.mvp
def test_snapshot_failed_missing_hdd_benchmark(app: Devicehub, user: UserClient):
""" This test check if the file snapshot is create when some snapshot is wrong """
tmp_snapshots = app.config['TMP_SNAPSHOTS']
snapshot_error = file('failed.snapshot.500.missing-hdd-benchmark')
uuid = snapshot_error['uuid']
snapshot = {'software': '', 'version': '', 'uuid': ''}
with pytest.raises(TypeError):
user.post(res=Snapshot, data=snapshot_error)
files = [x for x in os.listdir(tmp_snapshots) if uuid in x]
if files:
path_snapshot = os.path.join(tmp_snapshots, files[0])
with open(path_snapshot) as file_snapshot:
snapshot = json.loads(file_snapshot.read())
os.remove(path_snapshot)
assert snapshot['software'] == snapshot_error['software']
assert snapshot['version'] == snapshot_error['version']
assert snapshot['uuid'] == uuid
@pytest.mark.mvp
def test_snapshot_failed_null_chassis(app: Devicehub, user: UserClient):
""" This test check if the file snapshot is create when some snapshot is wrong """
tmp_snapshots = app.config['TMP_SNAPSHOTS']
snapshot_error = file('failed.snapshot.422.null-chassis')
uuid = snapshot_error['uuid']
snapshot = {'software': '', 'version': '', 'uuid': ''}
# import pdb; pdb.set_trace()
with pytest.raises(TypeError):
user.post(res=Snapshot, data=snapshot_error)
files = [x for x in os.listdir(tmp_snapshots) if uuid in x]
if files:
path_snapshot = os.path.join(tmp_snapshots, files[0])
with open(path_snapshot) as file_snapshot:
snapshot = json.loads(file_snapshot.read())
os.remove(path_snapshot)
assert snapshot['software'] == snapshot_error['software']
assert snapshot['version'] == snapshot_error['version']
assert snapshot['uuid'] == uuid
@pytest.mark.mvp
def test_snapshot_failed_missing_chassis(app: Devicehub, user: UserClient):
""" This test check if the file snapshot is create when some snapshot is wrong """
tmp_snapshots = app.config['TMP_SNAPSHOTS']
snapshot_error = file('failed.snapshot.422.missing-chassis')
uuid = snapshot_error['uuid']
snapshot = {'software': '', 'version': '', 'uuid': ''}
with pytest.raises(TypeError):
user.post(res=Snapshot, data=snapshot_error)
files = [x for x in os.listdir(tmp_snapshots) if uuid in x]
if files:
path_snapshot = os.path.join(tmp_snapshots, files[0])
with open(path_snapshot) as file_snapshot:
snapshot = json.loads(file_snapshot.read())
os.remove(path_snapshot)
assert snapshot['software'] == snapshot_error['software']
assert snapshot['version'] == snapshot_error['version']
assert snapshot['uuid'] == uuid