fixing test for jwt in snapshots
This commit is contained in:
parent
3d027270cc
commit
57007b3d92
|
@ -29,7 +29,7 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DisplayTech, Sever
|
|||
from ereuse_devicehub.resources.tag.model import Tag
|
||||
from ereuse_devicehub.resources.user import User
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -138,7 +138,7 @@ def test_physical_properties():
|
|||
@pytest.mark.usefixtures(conftest.auth_app_context.__name__)
|
||||
def test_component_similar_one():
|
||||
user = User.query.filter().first()
|
||||
snapshot = conftest.file('pc-components.db')
|
||||
snapshot = yaml2json('pc-components.db')
|
||||
pc = snapshot['device']
|
||||
snapshot['components'][0]['serial_number'] = snapshot['components'][1]['serial_number'] = None
|
||||
pc = d.Desktop(**pc, components=OrderedSet(d.Component(**c) for c in snapshot['components']))
|
||||
|
@ -167,7 +167,7 @@ def test_add_remove():
|
|||
# pc2 has c3
|
||||
# c4 is not with any pc
|
||||
user = User.query.filter().first()
|
||||
values = conftest.file('pc-components.db')
|
||||
values = yaml2json('pc-components.db')
|
||||
pc = values['device']
|
||||
c1, c2 = (d.Component(**c) for c in values['components'])
|
||||
pc = d.Desktop(**pc, components=OrderedSet([c1, c2]))
|
||||
|
@ -198,7 +198,7 @@ def test_sync_run_components_empty():
|
|||
"""Syncs a device that has an empty components list. The system should
|
||||
remove all the components from the device.
|
||||
"""
|
||||
s = conftest.file('pc-components.db')
|
||||
s = yaml2json('pc-components.db')
|
||||
pc = d.Desktop(**s['device'], components=OrderedSet(d.Component(**c) for c in s['components']))
|
||||
db.session.add(pc)
|
||||
db.session.commit()
|
||||
|
@ -216,7 +216,7 @@ def test_sync_run_components_none():
|
|||
"""Syncs a device that has a None components. The system should
|
||||
keep all the components from the device.
|
||||
"""
|
||||
s = conftest.file('pc-components.db')
|
||||
s = yaml2json('pc-components.db')
|
||||
pc = d.Desktop(**s['device'], components=OrderedSet(d.Component(**c) for c in s['components']))
|
||||
db.session.add(pc)
|
||||
db.session.commit()
|
||||
|
@ -233,7 +233,7 @@ def test_sync_run_components_none():
|
|||
def test_sync_execute_register_desktop_new_desktop_no_tag():
|
||||
"""Syncs a new d.Desktop with HID and without a tag, creating it."""
|
||||
# Case 1: device does not exist on DB
|
||||
pc = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
db_pc = Sync().execute_register(pc)
|
||||
assert pc.physical_properties == db_pc.physical_properties
|
||||
|
||||
|
@ -242,12 +242,12 @@ def test_sync_execute_register_desktop_new_desktop_no_tag():
|
|||
@pytest.mark.usefixtures(conftest.auth_app_context.__name__)
|
||||
def test_sync_execute_register_desktop_existing_no_tag():
|
||||
"""Syncs an existing d.Desktop with HID and without a tag."""
|
||||
pc = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
db.session.add(pc)
|
||||
db.session.commit()
|
||||
|
||||
pc = d.Desktop(
|
||||
**conftest.file('pc-components.db')['device']) # Create a new transient non-db object
|
||||
**yaml2json('pc-components.db')['device']) # Create a new transient non-db object
|
||||
# 1: device exists on DB
|
||||
db_pc = Sync().execute_register(pc)
|
||||
pc.amount = 0
|
||||
|
@ -262,7 +262,7 @@ def test_sync_execute_register_desktop_no_hid_no_tag(user: UserClient):
|
|||
"""Syncs a d.Desktop without HID and no tag.
|
||||
This should not fail as we don't have a way to identify it.
|
||||
"""
|
||||
device = conftest.file('pc-components.db')['device']
|
||||
device = yaml2json('pc-components.db')['device']
|
||||
device['owner_id'] = user.user['id']
|
||||
pc = d.Desktop(**device)
|
||||
# 1: device has no HID
|
||||
|
@ -283,7 +283,7 @@ def test_sync_execute_register_desktop_tag_not_linked():
|
|||
db.session.commit()
|
||||
|
||||
# Create a new transient non-db object
|
||||
pc = d.Desktop(**conftest.file('pc-components.db')['device'], tags=OrderedSet([Tag(id='foo')]))
|
||||
pc = d.Desktop(**yaml2json('pc-components.db')['device'], tags=OrderedSet([Tag(id='foo')]))
|
||||
returned_pc = Sync().execute_register(pc)
|
||||
assert returned_pc == pc
|
||||
assert tag.device == pc, 'Tag has to be linked'
|
||||
|
@ -300,7 +300,7 @@ def test_sync_execute_register_no_hid_tag_not_linked(tag_id: str):
|
|||
be linked), and thus it creates a new d.Desktop.
|
||||
"""
|
||||
tag = Tag(id=tag_id)
|
||||
pc = d.Desktop(**conftest.file('pc-components.db')['device'], tags=OrderedSet([tag]))
|
||||
pc = d.Desktop(**yaml2json('pc-components.db')['device'], tags=OrderedSet([tag]))
|
||||
db.session.add(g.user)
|
||||
returned_pc = Sync().execute_register(pc)
|
||||
db.session.commit()
|
||||
|
@ -323,7 +323,7 @@ def test_sync_execute_register_tag_does_not_exist():
|
|||
Tags have to be created before trying to link them through a Snapshot.
|
||||
"""
|
||||
user = User.query.filter().first()
|
||||
pc = d.Desktop(**conftest.file('pc-components.db')['device'], tags=OrderedSet([Tag('foo')]))
|
||||
pc = d.Desktop(**yaml2json('pc-components.db')['device'], tags=OrderedSet([Tag('foo')]))
|
||||
pc.owner_id = user.id
|
||||
with raises(ResourceNotFound):
|
||||
Sync().execute_register(pc)
|
||||
|
@ -337,12 +337,12 @@ def test_sync_execute_register_tag_linked_same_device():
|
|||
(If it has HID it validates both HID and tag point at the same
|
||||
device, this his checked in ).
|
||||
"""
|
||||
orig_pc = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
orig_pc = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
db.session.add(Tag(id='foo', device=orig_pc))
|
||||
db.session.commit()
|
||||
|
||||
pc = d.Desktop(
|
||||
**conftest.file('pc-components.db')['device']) # Create a new transient non-db object
|
||||
**yaml2json('pc-components.db')['device']) # Create a new transient non-db object
|
||||
pc.tags.add(Tag(id='foo'))
|
||||
db_pc = Sync().execute_register(pc)
|
||||
assert db_pc.id == orig_pc.id
|
||||
|
@ -356,16 +356,16 @@ def test_sync_execute_register_tag_linked_other_device_mismatch_between_tags():
|
|||
"""Checks that sync raises an error if finds that at least two passed-in
|
||||
tags are not linked to the same device.
|
||||
"""
|
||||
pc1 = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc1 = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
db.session.add(Tag(id='foo-1', device=pc1))
|
||||
pc2 = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc2 = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
pc2.serial_number = 'pc2-serial'
|
||||
pc2.hid = Naming.hid(pc2.type, pc2.manufacturer, pc2.model, pc2.serial_number)
|
||||
db.session.add(Tag(id='foo-2', device=pc2))
|
||||
db.session.commit()
|
||||
|
||||
pc1 = d.Desktop(
|
||||
**conftest.file('pc-components.db')['device']) # Create a new transient non-db object
|
||||
**yaml2json('pc-components.db')['device']) # Create a new transient non-db object
|
||||
pc1.tags.add(Tag(id='foo-1'))
|
||||
pc1.tags.add(Tag(id='foo-2'))
|
||||
with raises(MismatchBetweenTags):
|
||||
|
@ -380,16 +380,16 @@ def test_sync_execute_register_mismatch_between_tags_and_hid():
|
|||
|
||||
In this case we set HID -> pc1 but tag -> pc2
|
||||
"""
|
||||
pc1 = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc1 = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
db.session.add(Tag(id='foo-1', device=pc1))
|
||||
pc2 = d.Desktop(**conftest.file('pc-components.db')['device'])
|
||||
pc2 = d.Desktop(**yaml2json('pc-components.db')['device'])
|
||||
pc2.serial_number = 'pc2-serial'
|
||||
pc2.hid = Naming.hid(pc2.type, pc2.manufacturer, pc2.model, pc2.serial_number)
|
||||
db.session.add(Tag(id='foo-2', device=pc2))
|
||||
db.session.commit()
|
||||
|
||||
pc1 = d.Desktop(
|
||||
**conftest.file('pc-components.db')['device']) # Create a new transient non-db object
|
||||
**yaml2json('pc-components.db')['device']) # Create a new transient non-db object
|
||||
pc1.tags.add(Tag(id='foo-2'))
|
||||
with raises(MismatchBetweenTagsAndHid):
|
||||
Sync().execute_register(pc1)
|
||||
|
@ -623,9 +623,9 @@ def test_hid_with_mac(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_hid_without_mac(app: Devicehub, user: UserClient):
|
||||
"""Checks hid without mac."""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||
snapshot['components'] = [c for c in snapshot['components'] if c['type'] != 'NetworkAdapter']
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||
|
||||
|
@ -633,10 +633,10 @@ def test_hid_without_mac(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_hid_with_mac_none(app: Devicehub, user: UserClient):
|
||||
"""Checks hid with mac = None."""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||
network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0]
|
||||
network['serialNumber'] = None
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||
|
||||
|
@ -644,12 +644,12 @@ def test_hid_with_mac_none(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_hid_with_2networkadapters(app: Devicehub, user: UserClient):
|
||||
"""Checks hid with 2 networks adapters"""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||
network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0]
|
||||
network2 = copy.copy(network)
|
||||
snapshot['components'].append(network2)
|
||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
devices, _ = user.get(res=d.Device)
|
||||
|
||||
laptop = devices['items'][0]
|
||||
|
@ -660,18 +660,18 @@ def test_hid_with_2networkadapters(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClient):
|
||||
"""Checks hid with 2 networks adapters and next drop the network is not used in hid"""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||
network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0]
|
||||
network2 = copy.copy(network)
|
||||
snapshot['components'].append(network2)
|
||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||
|
||||
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
||||
snapshot['components'] = [c for c in snapshot['components'] if c != network]
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
devices, _ = user.get(res=d.Device)
|
||||
laptop = devices['items'][0]
|
||||
assert laptop['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||
|
@ -683,19 +683,19 @@ def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClie
|
|||
def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient):
|
||||
"""Checks hid with 2 networks adapters and next drop the network is used in hid"""
|
||||
# One tipical snapshot with 2 network cards
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot = yaml2json('asus-eee-1000h.snapshot.11')
|
||||
network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0]
|
||||
network2 = copy.copy(network)
|
||||
snapshot['components'].append(network2)
|
||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
snap, _ = user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116-00:24:8c:7f:cf:2d'
|
||||
|
||||
# we drop the network card then is used for to build the hid
|
||||
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abb'
|
||||
snapshot['components'] = [c for c in snapshot['components'] if c != network2]
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
devices, _ = user.get(res=d.Device)
|
||||
laptops = [c for c in devices['items'] if c['type'] == 'Laptop']
|
||||
assert len(laptops) == 2
|
||||
|
@ -707,7 +707,7 @@ def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient)
|
|||
# we drop all network cards
|
||||
snapshot['uuid'] = 'd1b70cb8-8929-4f36-99b7-fe052cec0abc'
|
||||
snapshot['components'] = [c for c in snapshot['components'] if not c in [network, network2]]
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
user.post(json_encode(snapshot), res=m.Snapshot)
|
||||
devices, _ = user.get(res=d.Device)
|
||||
laptops = [c for c in devices['items'] if c['type'] == 'Laptop']
|
||||
assert len(laptops) == 3
|
||||
|
|
|
@ -13,7 +13,7 @@ from ereuse_devicehub.resources.device.views import Filters, Sorting
|
|||
from ereuse_devicehub.resources.enums import ComputerChassis
|
||||
from ereuse_devicehub.resources.lot.models import Lot
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -196,9 +196,9 @@ def test_device_query_permitions(user: UserClient, user2: UserClient):
|
|||
i2, _ = user2.get(res=Device)
|
||||
assert i2['items'] == []
|
||||
|
||||
basic_snapshot = file('basic.snapshot')
|
||||
basic_snapshot = yaml2json('basic.snapshot')
|
||||
basic_snapshot['uuid'] = f"{uuid.uuid4()}"
|
||||
user2.post(basic_snapshot, res=Snapshot)
|
||||
user2.post(json_encode(basic_snapshot), res=Snapshot)
|
||||
i2, _ = user2.get(res=Device)
|
||||
pc2 = next(d for d in i2['items'] if d['type'] == 'Desktop')
|
||||
|
||||
|
@ -265,9 +265,9 @@ def test_device_query_search_synonyms_asus(user: UserClient):
|
|||
|
||||
@pytest.mark.mvp
|
||||
def test_device_query_search_synonyms_intel(user: UserClient):
|
||||
s = file('real-hp.snapshot.11')
|
||||
s = yaml2json('real-hp.snapshot.11')
|
||||
s['device']['model'] = 'foo' # The model had the word 'HP' in it
|
||||
user.post(s, res=Snapshot)
|
||||
user.post(json_encode(s), res=Snapshot)
|
||||
i, _ = user.get(res=Device, query=[('search', 'hewlett packard')])
|
||||
assert 1 == len(i['items'])
|
||||
i, _ = user.get(res=Device, query=[('search', 'hewlett')])
|
||||
|
|
|
@ -23,7 +23,7 @@ from ereuse_devicehub.resources.hash_reports import ReportHash
|
|||
from ereuse_devicehub.resources.enums import SessionType
|
||||
from ereuse_devicehub.db import db
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -114,8 +114,8 @@ def test_export_csv_permitions(user: UserClient, user2: UserClient, client: Clie
|
|||
@pytest.mark.mvp
|
||||
def test_export_csv_actions(user: UserClient, user2: UserClient, client: Client):
|
||||
"""Test export device information in a csv file with others users."""
|
||||
acer = file('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(acer, res=Snapshot)
|
||||
acer = yaml2json('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(json_encode(acer), res=Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"devices": [device_id], "description": "aaa",
|
||||
|
@ -156,8 +156,8 @@ def test_export_csv_actions(user: UserClient, user2: UserClient, client: Client)
|
|||
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||
def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub):
|
||||
"""Tests inserting a Live into the database and GETting it."""
|
||||
acer = file('acer-happy.snapshot-test1')
|
||||
snapshot, _ = user.post(acer, res=Snapshot)
|
||||
acer = yaml2json('acer-happy.snapshot-test1')
|
||||
snapshot, _ = user.post(json_encode(acer), res=Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"devices": [device_id], "description": "aaa",
|
||||
|
@ -168,7 +168,7 @@ def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub):
|
|||
|
||||
user.post(res=Allocate, data=post_request)
|
||||
|
||||
acer = file('acer-happy.live-test1')
|
||||
acer = yaml2json('acer-happy.live-test1')
|
||||
live, _ = client.post(acer, res=Live)
|
||||
csv_user, _ = user.get(res=documents.DocumentDef.t,
|
||||
item='actions/',
|
||||
|
@ -183,8 +183,8 @@ def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub):
|
|||
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||
def test_live_example2(user: UserClient, client: Client, app: Devicehub):
|
||||
"""Tests inserting a Live into the database and GETting it."""
|
||||
acer = file('acer-happy.snapshot-test1')
|
||||
snapshot, _ = user.post(acer, res=Snapshot)
|
||||
acer = yaml2json('acer-happy.snapshot-test1')
|
||||
snapshot, _ = user.post(json_encode(acer), res=Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"devices": [device_id], "description": "aaa",
|
||||
|
@ -195,7 +195,7 @@ def test_live_example2(user: UserClient, client: Client, app: Devicehub):
|
|||
|
||||
user.post(res=Allocate, data=post_request)
|
||||
|
||||
acer = file('acer-happy.live-test1')
|
||||
acer = yaml2json('acer-happy.live-test1')
|
||||
live, _ = client.post(acer, res=Live)
|
||||
db_device = d.Device.query.filter_by(id=device_id).one()
|
||||
action_live = [a for a in db_device.actions if a.type == 'Live']
|
||||
|
@ -553,8 +553,8 @@ def test_verify_stamp_devices_stock(user: UserClient, client: Client):
|
|||
@pytest.mark.mvp
|
||||
def test_verify_stamp_csv_actions(user: UserClient, client: Client):
|
||||
"""Test verify stamp of one export device information in a csv file with others users."""
|
||||
acer = file('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(acer, res=Snapshot)
|
||||
acer = yaml2json('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(json_encode(acer), res=Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"devices": [device_id], "description": "aaa",
|
||||
|
|
|
@ -3,7 +3,7 @@ import pytest
|
|||
from ereuse_devicehub.client import UserClient
|
||||
from ereuse_devicehub.resources.action import models as ma
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -11,10 +11,10 @@ from tests.conftest import file
|
|||
def test_simple_metrics(user: UserClient):
|
||||
""" Checks one standard query of metrics """
|
||||
# Insert computer
|
||||
lenovo = file('desktop-9644w8n-lenovo-0169622.snapshot')
|
||||
acer = file('acer.happy.battery.snapshot')
|
||||
user.post(lenovo, res=ma.Snapshot)
|
||||
snapshot, _ = user.post(acer, res=ma.Snapshot)
|
||||
lenovo = yaml2json('desktop-9644w8n-lenovo-0169622.snapshot')
|
||||
acer = yaml2json('acer.happy.battery.snapshot')
|
||||
user.post(json_encode(lenovo), res=ma.Snapshot)
|
||||
snapshot, _ = user.post(json_encode(acer), res=ma.Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"finalUserCode": "abcdefjhi",
|
||||
|
@ -58,8 +58,8 @@ def test_simple_metrics(user: UserClient):
|
|||
def test_second_hdd_metrics(user: UserClient):
|
||||
""" Checks one standard query of metrics """
|
||||
# Insert computer
|
||||
acer = file('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(acer, res=ma.Snapshot)
|
||||
acer = yaml2json('acer.happy.battery.snapshot')
|
||||
snapshot, _ = user.post(json_encode(acer), res=ma.Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
post_request = {"transaction": "ccc", "name": "John", "endUsers": 1,
|
||||
"finalUserCode": "abcdefjhi",
|
||||
|
|
|
@ -12,7 +12,7 @@ from ereuse_devicehub.resources.device.models import Computer, Desktop, Device,
|
|||
from ereuse_devicehub.resources.enums import AppearanceRange, ComputerChassis, \
|
||||
FunctionalityRange
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -104,16 +104,16 @@ def test_when_rate_must_not_compute(user: UserClient):
|
|||
...
|
||||
"""
|
||||
# Checking case 1
|
||||
s = file('basic.snapshot')
|
||||
s = yaml2json('basic.snapshot')
|
||||
# Delete snapshot device actions to delete VisualTest
|
||||
del s['device']['actions']
|
||||
|
||||
# Post to compute rate and check to didn't do it
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
snapshot, _ = user.post(json_encode(s), res=Snapshot)
|
||||
assert 'rate' not in snapshot['device']
|
||||
|
||||
# Checking case 2
|
||||
s = file('basic.snapshot')
|
||||
s = yaml2json('basic.snapshot')
|
||||
# Change snapshot software source
|
||||
s['software'] = 'Web'
|
||||
del s['uuid']
|
||||
|
@ -121,14 +121,14 @@ def test_when_rate_must_not_compute(user: UserClient):
|
|||
del s['components']
|
||||
|
||||
# Post to compute rate and check to didn't do it
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
snapshot, _ = user.post(json_encode(s), res=Snapshot)
|
||||
assert 'rate' not in snapshot['device']
|
||||
|
||||
# Checking case 3
|
||||
s = file('keyboard.snapshot')
|
||||
s = yaml2json('keyboard.snapshot')
|
||||
|
||||
# Post to compute rate and check to didn't do it
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
snapshot, _ = user.post(json_encode(s), res=Snapshot)
|
||||
assert 'rate' not in snapshot['device']
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ from ereuse_devicehub.resources.tag import Tag
|
|||
from ereuse_devicehub.resources.user.models import User
|
||||
from ereuse_devicehub.resources.action.views.snapshot import save_json
|
||||
from ereuse_devicehub.resources.documents import documents
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
from tests import conftest
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ def test_snapshot_model():
|
|||
@pytest.mark.mvp
|
||||
def test_snapshot_schema(app: Devicehub):
|
||||
with app.app_context():
|
||||
s = file('basic.snapshot')
|
||||
s = yaml2json('basic.snapshot')
|
||||
app.resources['Snapshot'].schema.load(s)
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ def test_snapshot_post(user: UserClient):
|
|||
"""Tests the post snapshot endpoint (validation, etc), data correctness,
|
||||
and relationship correctness.
|
||||
"""
|
||||
snapshot = snapshot_and_check(user, file('basic.snapshot'),
|
||||
snapshot = snapshot_and_check(user, yaml2json('basic.snapshot'),
|
||||
action_types=(
|
||||
BenchmarkProcessor.t,
|
||||
VisualTest.t,
|
||||
|
@ -112,16 +112,16 @@ def test_snapshot_post(user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_same_device_tow_users(user: UserClient, user2: UserClient):
|
||||
"""Two users can up the same snapshot and the system save 2 computers"""
|
||||
user.post(file('basic.snapshot'), res=Snapshot)
|
||||
user.post(yaml2json('basic.snapshot'), res=Snapshot)
|
||||
i, _ = user.get(res=m.Device)
|
||||
pc = next(d for d in i['items'] if d['type'] == 'Desktop')
|
||||
pc_id = pc['id']
|
||||
devicehub_id = pc['devicehubID']
|
||||
assert i['items'][0]['url'] == f'/devices/{devicehub_id}'
|
||||
|
||||
basic_snapshot = file('basic.snapshot')
|
||||
basic_snapshot = yaml2json('basic.snapshot')
|
||||
basic_snapshot['uuid'] = f"{uuid.uuid4()}"
|
||||
user2.post(basic_snapshot, res=Snapshot)
|
||||
user2.post(json_encode(basic_snapshot), res=Snapshot)
|
||||
i2, _ = user2.get(res=m.Device)
|
||||
pc2 = next(d for d in i2['items'] if d['type'] == 'Desktop')
|
||||
assert pc['id'] != pc2['id']
|
||||
|
@ -133,13 +133,13 @@ def test_snapshot_update_timefield_updated(user: UserClient):
|
|||
"""
|
||||
Tests for check if one computer have the time mark updated when one component of it is updated
|
||||
"""
|
||||
computer1 = file('1-device-with-components.snapshot')
|
||||
computer1 = yaml2json('1-device-with-components.snapshot')
|
||||
snapshot = snapshot_and_check(user,
|
||||
computer1,
|
||||
action_types=(BenchmarkProcessor.t,
|
||||
RateComputer.t),
|
||||
perform_second_snapshot=False)
|
||||
computer2 = file('2-second-device-with-components-of-first.snapshot')
|
||||
computer2 = yaml2json('2-second-device-with-components-of-first.snapshot')
|
||||
snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'),
|
||||
perform_second_snapshot=False)
|
||||
pc1_devicehub_id = snapshot['device']['devicehubID']
|
||||
|
@ -165,7 +165,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# We add the first device (2 times). The distribution of components
|
||||
# (represented with their S/N) should be:
|
||||
# PC 1: p1c1s, p1c2s, p1c3s. PC 2: ø
|
||||
s1 = file('1-device-with-components.snapshot')
|
||||
s1 = yaml2json('1-device-with-components.snapshot')
|
||||
snapshot1 = snapshot_and_check(user,
|
||||
s1,
|
||||
action_types=(BenchmarkProcessor.t,
|
||||
|
@ -190,7 +190,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# It has the processor of the first one (p1c2s)
|
||||
# PC 1: p1c1s, p1c3s. PC 2: p2c1s, p1c2s
|
||||
# Actions PC1: Snapshot, Remove. PC2: Snapshot
|
||||
s2 = file('2-second-device-with-components-of-first.snapshot')
|
||||
s2 = yaml2json('2-second-device-with-components-of-first.snapshot')
|
||||
# num_actions = 2 = Remove, Add
|
||||
snapshot2 = snapshot_and_check(user, s2, action_types=('Remove', 'RateComputer'),
|
||||
perform_second_snapshot=False)
|
||||
|
@ -220,7 +220,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# and moving processor from the second device to the first.
|
||||
# We have created 1 Remove (from PC2's processor back to PC1)
|
||||
# PC 0: p1c2s, p1c3s. PC 1: p2c1s
|
||||
s3 = file('3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot')
|
||||
s3 = yaml2json('3-first-device-but-removing-motherboard-and-adding-processor-from-2.snapshot')
|
||||
snapshot_and_check(user, s3, ('Remove', 'RateComputer'), perform_second_snapshot=False)
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
|
||||
|
@ -266,7 +266,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
|
||||
# We register the first device but without the processor,
|
||||
# adding a graphic card and adding a new component
|
||||
s4 = file('4-first-device-but-removing-processor.snapshot-and-adding-graphic-card')
|
||||
s4 = yaml2json('4-first-device-but-removing-processor.snapshot-and-adding-graphic-card')
|
||||
snapshot4 = snapshot_and_check(user, s4, ('RateComputer',), perform_second_snapshot=False)
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
|
||||
|
@ -312,7 +312,7 @@ def test_snapshot_mismatch_id():
|
|||
@pytest.mark.mvp
|
||||
def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub):
|
||||
"""Tests a posting Snapshot with a local tag."""
|
||||
b = file('basic.snapshot')
|
||||
b = yaml2json('basic.snapshot')
|
||||
b['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
|
||||
|
||||
snapshot_and_check(user, b,
|
||||
|
@ -325,13 +325,13 @@ def test_snapshot_tag_inner_tag(user: UserClient, tag_id: str, app: Devicehub):
|
|||
@pytest.mark.mvp
|
||||
def test_snapshot_tag_inner_tag_mismatch_between_tags_and_hid(user: UserClient, tag_id: str):
|
||||
"""Ensures one device cannot 'steal' the tag from another one."""
|
||||
pc1 = file('basic.snapshot')
|
||||
pc1 = yaml2json('basic.snapshot')
|
||||
pc1['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
|
||||
user.post(pc1, res=Snapshot)
|
||||
pc2 = file('1-device-with-components.snapshot')
|
||||
user.post(pc2, res=Snapshot) # PC2 uploads well
|
||||
user.post(json_encode(pc1), res=Snapshot)
|
||||
pc2 = yaml2json('1-device-with-components.snapshot')
|
||||
user.post(json_encode(pc2), res=Snapshot) # PC2 uploads well
|
||||
pc2['device']['tags'] = [{'type': 'Tag', 'id': tag_id}] # Set tag from pc1 to pc2
|
||||
user.post(pc2, res=Snapshot, status=MismatchBetweenTagsAndHid)
|
||||
user.post(json_encode(pc2), res=Snapshot, status=MismatchBetweenTagsAndHid)
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -341,17 +341,17 @@ def test_snapshot_different_properties_same_tags(user: UserClient, tag_id: str):
|
|||
Devicehub must fail the Snapshot.
|
||||
"""
|
||||
# 1. Upload PC1 without hid but with tag
|
||||
pc1 = file('basic.snapshot')
|
||||
pc1 = yaml2json('basic.snapshot')
|
||||
pc1['device']['tags'] = [{'type': 'Tag', 'id': tag_id}]
|
||||
del pc1['device']['serialNumber']
|
||||
user.post(pc1, res=Snapshot)
|
||||
user.post(json_encode(pc1), res=Snapshot)
|
||||
# 2. Upload PC2 without hid, a different characteristic than PC1, but with same tag
|
||||
pc2 = file('basic.snapshot')
|
||||
pc2 = yaml2json('basic.snapshot')
|
||||
pc2['uuid'] = uuid4()
|
||||
pc2['device']['tags'] = pc1['device']['tags']
|
||||
# pc2 model is unknown but pc1 model is set = different property
|
||||
del pc2['device']['model']
|
||||
user.post(pc2, res=Snapshot, status=MismatchBetweenProperties)
|
||||
user.post(json_encode(pc2), res=Snapshot, status=MismatchBetweenProperties)
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -368,14 +368,14 @@ def test_snapshot_component_containing_components(user: UserClient):
|
|||
|
||||
This test avoids this until an appropriate use-case is presented.
|
||||
"""
|
||||
s = file('basic.snapshot')
|
||||
s = yaml2json('basic.snapshot')
|
||||
s['device'] = {
|
||||
'type': 'Processor',
|
||||
'serialNumber': 'foo',
|
||||
'manufacturer': 'bar',
|
||||
'model': 'baz'
|
||||
}
|
||||
user.post(s, res=Snapshot, status=ValidationError)
|
||||
user.post(json_encode(s), res=Snapshot, status=ValidationError)
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -386,7 +386,7 @@ def test_ereuse_price(user: UserClient):
|
|||
This tests ensures that only the last erasure is picked up, as
|
||||
erasures have always custom endTime value set.
|
||||
"""
|
||||
s = file('erase-sectors.snapshot')
|
||||
s = yaml2json('erase-sectors.snapshot')
|
||||
assert s['components'][0]['actions'][0]['endTime'] == '2018-06-01T09:12:06+02:00'
|
||||
s['device']['type'] = 'Server'
|
||||
snapshot = snapshot_and_check(user, s, action_types=(
|
||||
|
@ -408,7 +408,7 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient):
|
|||
This tests ensures that only the last erasure is picked up, as
|
||||
erasures have always custom endTime value set.
|
||||
"""
|
||||
s = file('erase-sectors.snapshot')
|
||||
s = yaml2json('erase-sectors.snapshot')
|
||||
assert s['components'][0]['actions'][0]['endTime'] == '2018-06-01T09:12:06+02:00'
|
||||
snapshot = snapshot_and_check(user, s, action_types=(
|
||||
EraseSectors.t,
|
||||
|
@ -594,7 +594,7 @@ def test_pc_2(user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_save_snapshot_in_file(app: Devicehub, user: UserClient):
|
||||
""" This test check if works the function save_snapshot_in_file """
|
||||
snapshot_no_hid = file('basic.snapshot.nohid')
|
||||
snapshot_no_hid = yaml2json('basic.snapshot.nohid')
|
||||
tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
|
||||
|
@ -638,9 +638,9 @@ def test_action_no_snapshot_without_save_file(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_save_snapshot_with_debug(app: Devicehub, user: UserClient):
|
||||
""" This test check if works the function save_snapshot_in_file """
|
||||
snapshot_file = file('basic.snapshot.with_debug')
|
||||
snapshot_file = yaml2json('basic.snapshot.with_debug')
|
||||
debug = snapshot_file['debug']
|
||||
user.post(res=Snapshot, data=snapshot_file)
|
||||
user.post(res=Snapshot, data=json_encode(snapshot_file))
|
||||
|
||||
tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'])
|
||||
|
@ -664,12 +664,12 @@ def test_backup_snapshot_with_errors(app: Devicehub, user: UserClient):
|
|||
""" This test check if the file snapshot is create when some snapshot is wrong """
|
||||
tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_no_hid = file('basic.snapshot.badly_formed')
|
||||
snapshot_no_hid = yaml2json('basic.snapshot.badly_formed')
|
||||
uuid = snapshot_no_hid['uuid']
|
||||
|
||||
snapshot = {'software': '', 'version': '', 'uuid': ''}
|
||||
with pytest.raises(KeyError):
|
||||
response = user.post(res=Snapshot, data=snapshot_no_hid)
|
||||
response = user.post(res=Snapshot, data=json_encode(snapshot_no_hid))
|
||||
|
||||
files = [x for x in os.listdir(path_dir_base) if uuid in x]
|
||||
if files:
|
||||
|
@ -689,12 +689,12 @@ 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']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_error = file('failed.snapshot.500.missing-cpu-benchmark')
|
||||
snapshot_error = yaml2json('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)
|
||||
user.post(res=Snapshot, data=json_encode(snapshot_error))
|
||||
|
||||
files = [x for x in os.listdir(path_dir_base) if uuid in x]
|
||||
if files:
|
||||
|
@ -714,12 +714,12 @@ 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']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_error = file('failed.snapshot.500.missing-hdd-benchmark')
|
||||
snapshot_error = yaml2json('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)
|
||||
user.post(res=Snapshot, data=json_encode(snapshot_error))
|
||||
|
||||
files = [x for x in os.listdir(path_dir_base) if uuid in x]
|
||||
if files:
|
||||
|
@ -739,11 +739,11 @@ def test_snapshot_not_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']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_error = file('desktop-9644w8n-lenovo-0169622.snapshot')
|
||||
snapshot_error = yaml2json('desktop-9644w8n-lenovo-0169622.snapshot')
|
||||
snapshot_error['device']['chassis'] = None
|
||||
uuid = snapshot_error['uuid']
|
||||
|
||||
snapshot, res = user.post(res=Snapshot, data=snapshot_error)
|
||||
snapshot, res = user.post(res=Snapshot, data=json_encode(snapshot_error))
|
||||
|
||||
shutil.rmtree(tmp_snapshots)
|
||||
|
||||
|
@ -757,12 +757,12 @@ 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']
|
||||
path_dir_base = os.path.join(tmp_snapshots, user.user['email'], 'errors')
|
||||
snapshot_error = file('failed.snapshot.422.missing-chassis')
|
||||
snapshot_error = yaml2json('failed.snapshot.422.missing-chassis')
|
||||
uuid = snapshot_error['uuid']
|
||||
|
||||
snapshot = {'software': '', 'version': '', 'uuid': ''}
|
||||
with pytest.raises(TypeError):
|
||||
user.post(res=Snapshot, data=snapshot_error)
|
||||
user.post(res=Snapshot, data=json_encode(snapshot_error))
|
||||
|
||||
files = [x for x in os.listdir(path_dir_base) if uuid in x]
|
||||
if files:
|
||||
|
@ -798,9 +798,9 @@ def test_snapshot_not_failed_end_time_bug(app: Devicehub, user: UserClient):
|
|||
""" This test check if the end_time != 0001-01-01 00:00:00+00:00
|
||||
and then we get a /devices, this create a crash
|
||||
"""
|
||||
snapshot_file = file('asus-end_time_bug88.snapshot')
|
||||
snapshot_file = yaml2json('asus-end_time_bug88.snapshot')
|
||||
snapshot_file['endTime'] = '2001-01-01 00:00:00+00:00'
|
||||
snapshot, _ = user.post(res=Snapshot, data=snapshot_file)
|
||||
snapshot, _ = user.post(res=Snapshot, data=json_encode(snapshot_file))
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
end_times = [x['endTime'] for x in device['actions']]
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from ereuse_devicehub.resources.tag import Tag
|
|||
from ereuse_devicehub.resources.tag.view import CannotCreateETag, LinkedToAnotherDevice, \
|
||||
TagNotLinked
|
||||
from tests import conftest
|
||||
from tests.conftest import file
|
||||
from tests.conftest import file, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -319,9 +319,9 @@ def test_tag_secondary_workbench_link_find(user: UserClient):
|
|||
with pytest.raises(ResourceNotFound):
|
||||
Tag.from_an_id('nope').one()
|
||||
|
||||
s = file('basic.snapshot')
|
||||
s = yaml2json('basic.snapshot')
|
||||
s['device']['tags'] = [{'id': 'foo', 'secondary': 'bar', 'type': 'Tag'}]
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
snapshot, _ = user.post(json_encode(s), res=Snapshot)
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert device['tags'][0]['id'] == 'foo'
|
||||
assert device['tags'][0]['secondary'] == 'bar'
|
||||
|
|
|
@ -11,7 +11,7 @@ from ereuse_devicehub.resources.action.models import RateComputer, BenchmarkProc
|
|||
from ereuse_devicehub.resources.device.exceptions import NeedsId
|
||||
from ereuse_devicehub.resources.device.models import Device
|
||||
from ereuse_devicehub.resources.tag.model import Tag
|
||||
from tests.conftest import file, file_workbench
|
||||
from tests.conftest import file, file_workbench, yaml2json, json_encode
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -20,18 +20,18 @@ def test_workbench_server_condensed(user: UserClient):
|
|||
condensed in only one big ``Snapshot`` file, as described
|
||||
in the docs.
|
||||
"""
|
||||
s = file('workbench-server-1.snapshot')
|
||||
s['device']['actions'].append(file('workbench-server-2.stress-test'))
|
||||
s = yaml2json('workbench-server-1.snapshot')
|
||||
s['device']['actions'].append(yaml2json('workbench-server-2.stress-test'))
|
||||
s['components'][4]['actions'].extend((
|
||||
file('workbench-server-3.erase'),
|
||||
file('workbench-server-4.install')
|
||||
yaml2json('workbench-server-3.erase'),
|
||||
yaml2json('workbench-server-4.install')
|
||||
))
|
||||
s['components'][5]['actions'].append(file('workbench-server-3.erase'))
|
||||
s['components'][5]['actions'].append(yaml2json('workbench-server-3.erase'))
|
||||
# Create tags
|
||||
for t in s['device']['tags']:
|
||||
user.post({'id': t['id']}, res=Tag)
|
||||
|
||||
snapshot, _ = user.post(res=em.Snapshot, data=s)
|
||||
snapshot, _ = user.post(res=em.Snapshot, data=json_encode(s))
|
||||
pc_id = snapshot['device']['id']
|
||||
cpu_id = snapshot['components'][3]['id']
|
||||
ssd_id= snapshot['components'][4]['id']
|
||||
|
@ -77,28 +77,28 @@ def test_workbench_server_phases(user: UserClient):
|
|||
actions.html#snapshots-from-workbench>`_.
|
||||
"""
|
||||
# 1. Snapshot with sync / rate / benchmarks / test data storage
|
||||
s = file('workbench-server-1.snapshot')
|
||||
snapshot, _ = user.post(res=em.Snapshot, data=s)
|
||||
s = yaml2json('workbench-server-1.snapshot')
|
||||
snapshot, _ = user.post(res=em.Snapshot, data=json_encode(s))
|
||||
assert not snapshot['closed'], 'Snapshot must be waiting for the new actions'
|
||||
|
||||
# 2. stress test
|
||||
st = file('workbench-server-2.stress-test')
|
||||
st = yaml2json('workbench-server-2.stress-test')
|
||||
st['snapshot'] = snapshot['id']
|
||||
stress_test, _ = user.post(res=em.StressTest, data=st)
|
||||
|
||||
# 3. erase
|
||||
ssd_id, hdd_id = snapshot['components'][4]['id'], snapshot['components'][5]['id']
|
||||
e = file('workbench-server-3.erase')
|
||||
e = yaml2json('workbench-server-3.erase')
|
||||
e['snapshot'], e['device'] = snapshot['id'], ssd_id
|
||||
erase1, _ = user.post(res=em.EraseSectors, data=e)
|
||||
|
||||
# 3 bis. a second erase
|
||||
e = file('workbench-server-3.erase')
|
||||
e = yaml2json('workbench-server-3.erase')
|
||||
e['snapshot'], e['device'] = snapshot['id'], hdd_id
|
||||
erase2, _ = user.post(res=em.EraseSectors, data=e)
|
||||
|
||||
# 4. Install
|
||||
i = file('workbench-server-4.install')
|
||||
i = yaml2json('workbench-server-4.install')
|
||||
i['snapshot'], i['device'] = snapshot['id'], ssd_id
|
||||
install, _ = user.post(res=em.Install, data=i)
|
||||
|
||||
|
@ -317,7 +317,7 @@ def test_workbench_fixtures(file: pathlib.Path, user: UserClient):
|
|||
"""
|
||||
s = json.load(file.open())
|
||||
user.post(res=em.Snapshot,
|
||||
data=s,
|
||||
data=json_encode(s),
|
||||
status=201)
|
||||
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0eXBlIjoiU25hcHNob3QiLCJ1dWlkIjoiMDA0MWQ4ZTgtNTY5Yy00NDUyLWIyOTktMDc0YjVmY2M2NDIyIiwic29mdHdhcmUiOiJXb3JrYmVuY2giLCJ2ZXJzaW9uIjoiMTIuMGIwIiwiY2xvc2VkIjp0cnVlLCJlbmRUaW1lIjoiMjAyMS0wNi0yOVQxMzo0NzoxNi42MTI5NjkrMDA6MDAiLCJlbGFwc2VkIjozMSwiZGV2aWNlIjp7ImFjdGlvbnMiOlt7ImVsYXBzZWQiOjEwLCJ0eXBlIjoiQmVuY2htYXJrUmFtU3lzYmVuY2giLCJyYXRlIjoxMC4wMDAxfV0sInR5cGUiOiJDb21wdXRlciIsIm1hbnVmYWN0dXJlciI6IkludGVsIENsaWVudCBTeXN0ZW1zIiwibW9kZWwiOiJOVUM2Q0FZSCIsInNlcmlhbE51bWJlciI6Ikc2QVk5MjIwMEw3OCIsImNoYXNzaXMiOiJWaXJ0dWFsIiwic2t1IjpudWxsLCJ2ZXJzaW9uIjoiSjI2ODQzLTQwOSJ9LCJjb21wb25lbnRzIjpbeyJhY3Rpb25zIjpbeyJlbGFwc2VkIjoxMCwidHlwZSI6IkJlbmNobWFya1Byb2Nlc3NvclN5c2JlbmNoIiwicmF0ZSI6MTAuMDA2NH0seyJlbGFwc2VkIjowLCJ0eXBlIjoiQmVuY2htYXJrUHJvY2Vzc29yIiwicmF0ZSI6MTE5ODAuOH1dLCJ0eXBlIjoiUHJvY2Vzc29yIiwibWFudWZhY3R1cmVyIjoiSW50ZWwgQ29ycC4iLCJtb2RlbCI6IkludGVsIENlbGVyb24gQ1BVIEozNDU1IEAgMS41MEdIeiIsInNlcmlhbE51bWJlciI6bnVsbCwic3BlZWQiOjEuODIxNjk0MDAwMDAwMDAwMSwiYWRkcmVzcyI6NjQsImNvcmVzIjo0LCJ0aHJlYWRzIjo0LCJicmFuZCI6IkNlbGVyb24iLCJnZW5lcmF0aW9uIjpudWxsfSx7ImFjdGlvbnMiOltdLCJ0eXBlIjoiUmFtTW9kdWxlIiwibWFudWZhY3R1cmVyIjoiVW5kZSIsIm1vZGVsIjoiQ1Q0RzNTMTg2REpNLk04RlAiLCJzZXJpYWxOdW1iZXIiOiJFMDgyMjRGRSIsImZvcm1hdCI6IlNPRElNTSIsInNpemUiOjQwOTYuMCwiaW50ZXJmYWNlIjoiRERSMyIsInNwZWVkIjoxODY2LjB9LHsiYWN0aW9ucyI6W3siZWxhcHNlZCI6MiwidHlwZSI6IkJlbmNobWFya0RhdGFTdG9yYWdlIiwicmVhZFNwZWVkIjozNjUuMCwid3JpdGVTcGVlZCI6MTYxLjB9XSwidHlwZSI6IkhhcmREcml2ZSIsIm1hbnVmYWN0dXJlciI6bnVsbCwibW9kZWwiOiJLSU5HU1RPTiBTQTQwMFMzIiwic2VyaWFsTnVtYmVyIjoiNTAwMjZCNzM4MEM5MTA5QSIsInNpemUiOjEyMDAzNC4xMjM3NzYsImludGVyZmFjZSI6IkFUQSIsInZhcmlhbnQiOiJCMUg1In0seyJhY3Rpb25zIjpbXSwidHlwZSI6IkdyYXBoaWNDYXJkIiwibWFudWZhY3R1cmVyIjoiSW50ZWwgQ29ycG9yYXRpb24iLCJtb2RlbCI6IkludGVsIENvcnBvcmF0aW9uIiwic2VyaWFsTnVtYmVyIjpudWxsLCJtZW1vcnkiOm51bGx9LHsiYWN0aW9ucyI6W10sInR5cGUiOiJOZXR3b3JrQWRhcHRlciIsIm1hbnVmYWN0dXJlciI6IkludGVsIENvcnBvcmF0aW9uIiwibW9kZWwiOiJJbnRlbCBDb3Jwb3JhdGlvbiIsInNlcmlhbE51bWJlciI6bnVsbCwic3BlZWQiOm51bGwsInZhcmlhbnQiOiIxMCIsIndpcmVsZXNzIjpmYWxzZX0seyJhY3Rpb25zIjpbXSwidHlwZSI6Ik5ldHdvcmtBZGFwdGVyIiwibWFudWZhY3R1cmVyIjoiUmVhbHRlayBTZW1pY29uZHVjdG9yIENvLiwgTHRkLiIsIm1vZGVsIjoiUlRMODExMS84MTY4Lzg0MTEgUENJIEV4cHJlc3MgR2lnYWJpdCBFdGhlcm5ldCBDb250cm9sbGVyIiwic2VyaWFsTnVtYmVyIjoiMWM6Njk6N2E6MDM6ODU6ZWQiLCJzcGVlZCI6MTAwMC4wLCJ2YXJpYW50IjoiMTUiLCJ3aXJlbGVzcyI6ZmFsc2V9LHsiYWN0aW9ucyI6W10sInR5cGUiOiJTb3VuZENhcmQiLCJtYW51ZmFjdHVyZXIiOiJJbnRlbCBDb3Jwb3JhdGlvbiIsIm1vZGVsIjoiQXRvbS9DZWxlcm9uL1BlbnRpdW0gUHJvY2Vzc29yIE40MjAwL04zMzUwL0UzOTAwIFNlcmllcyBBdWRpbyBDbHVzdGVyIiwic2VyaWFsTnVtYmVyIjpudWxsfSx7ImFjdGlvbnMiOltdLCJ0eXBlIjoiTW90aGVyYm9hcmQiLCJtYW51ZmFjdHVyZXIiOiJJbnRlbCBDb3Jwb3JhdGlvbiIsIm1vZGVsIjoiTlVDNkNBWUIiLCJzZXJpYWxOdW1iZXIiOiJHRUFZOTIxMDBVUjUiLCJ1c2IiOjEsImZpcmV3aXJlIjowLCJzZXJpYWwiOjIsInBjbWNpYSI6MCwic2xvdHMiOjAsImJpb3NEYXRlIjoiMjAxOS0wMi0xOVQwMDowMDowMCIsInZlcnNpb24iOiJBWUFQTENFTC44NkEuMDA2MC4yMDE5LjAyMTkuMTUyNyIsInJhbVNsb3RzIjo0LCJyYW1NYXhTaXplIjozMn1dfQ.7HgnMZhOIqczfYOHyqKp0YcdWBZxj2P7vbe8RbDcGpU
|
Reference in New Issue