swap SystemID for DevicehubID
This commit is contained in:
parent
840674e83b
commit
b83563e0ea
|
@ -95,6 +95,7 @@ class Dummy:
|
|||
s, _ = user1.post(res=m.Snapshot, data=snapshot)
|
||||
if s.get('uuid', None) == 'ec23c11b-80b6-42cd-ac5c-73ba7acddbc4':
|
||||
sample_pc = s['device']['id']
|
||||
sample_pc_devicehub_id = s['device']['devicehubID']
|
||||
else:
|
||||
pcs.add(s['device']['id'])
|
||||
if s.get('uuid', None) == 'de4f495e-c58b-40e1-a33e-46ab5e84767e': # oreo
|
||||
|
@ -180,9 +181,9 @@ class Dummy:
|
|||
res=m.Action)
|
||||
# todo Receive
|
||||
|
||||
user1.get(res=Device, item=sample_pc) # Test
|
||||
user1.get(res=Device, item=sample_pc_devicehub_id) # Test
|
||||
anonymous = self.app.test_client()
|
||||
html, _ = anonymous.get(res=Device, item=sample_pc, accept=ANY)
|
||||
html, _ = anonymous.get(res=Device, item=sample_pc_devicehub_id, accept=ANY)
|
||||
assert 'intel core2 duo cpu' in html
|
||||
|
||||
# For netbook: to preapre -> torepair -> to dispose -> disposed
|
||||
|
|
|
@ -32,7 +32,7 @@ def upgrade_data():
|
|||
devices = con.execute(f"select id from {get_inv()}.device")
|
||||
for d in devices:
|
||||
id_dev = d.id
|
||||
code = hashcode(d.id)
|
||||
code = hashcode.encode(d.id)
|
||||
sql = f"update {get_inv()}.device set devicehub_id='{code}' where id={id_dev};"
|
||||
con.execute(sql)
|
||||
|
||||
|
@ -44,5 +44,6 @@ def upgrade():
|
|||
|
||||
upgrade_data()
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('device', 'devicehub_id', schema=f'{get_inv()}')
|
||||
|
|
|
@ -10,7 +10,7 @@ from ereuse_devicehub.resources.device.views import DeviceView, DeviceMergeView,
|
|||
class DeviceDef(Resource):
|
||||
SCHEMA = schemas.Device
|
||||
VIEW = DeviceView
|
||||
ID_CONVERTER = Converters.int
|
||||
ID_CONVERTER = Converters.string
|
||||
AUTH = False # We manage this at each view
|
||||
|
||||
def __init__(self, app,
|
||||
|
|
|
@ -374,7 +374,7 @@ class Device(Thing):
|
|||
|
||||
if act.type == 'Allocate':
|
||||
allo = {'type': 'Allocate',
|
||||
'systemId': self.id,
|
||||
'devicehubID': self.devicehub_id,
|
||||
'finalUserCode': act.final_user_code,
|
||||
'numEndUsers': act.end_users,
|
||||
'hid': self.hid,
|
||||
|
@ -395,7 +395,7 @@ class Device(Thing):
|
|||
|
||||
if act.type == 'Deallocate':
|
||||
deallo = {'type': 'Deallocate',
|
||||
'systemId': self.id,
|
||||
'devicehubID': self.devicehub_id,
|
||||
'finalUserCode': '',
|
||||
'numEndUsers': '',
|
||||
'hid': self.hid,
|
||||
|
@ -1035,13 +1035,3 @@ class Manufacturer(db.Model):
|
|||
|
||||
listener_reset_field_updated_in_actual_time(Device)
|
||||
|
||||
|
||||
# def create_code(mapper, connection, thing_obj):
|
||||
# """ This function create the code for every device."""
|
||||
# thing_obj.code = Hashids(thing_obj.id)
|
||||
|
||||
# def listener_create_code(thing_obj):
|
||||
# """ This function launch a event than listen like a signal when some device is create."""
|
||||
# event.listen(thing_obj, 'before_create', create_code)
|
||||
|
||||
# listener_create_code(Device)
|
||||
|
|
|
@ -118,7 +118,7 @@ class DeviceView(View):
|
|||
return Response(status=204)
|
||||
raise ValueError('Cannot patch a non computer')
|
||||
|
||||
def one(self, id: int):
|
||||
def one(self, id: str):
|
||||
"""Gets one device."""
|
||||
if not request.authorization:
|
||||
return self.one_public(id)
|
||||
|
@ -126,12 +126,12 @@ class DeviceView(View):
|
|||
return self.one_private(id)
|
||||
|
||||
def one_public(self, id: int):
|
||||
device = Device.query.filter_by(id=id).one()
|
||||
device = Device.query.filter_by(devicehub_id=id).one()
|
||||
return render_template('devices/layout.html', device=device, states=states)
|
||||
|
||||
@auth.Auth.requires_auth
|
||||
def one_private(self, id: int):
|
||||
device = Device.query.filter_by(id=id, owner_id=g.user.id).first()
|
||||
def one_private(self, id: str):
|
||||
device = Device.query.filter_by(devicehub_id=id, owner_id=g.user.id).first()
|
||||
if not device:
|
||||
return self.one_public(id)
|
||||
return self.schema.jsonify(device)
|
||||
|
|
|
@ -42,10 +42,10 @@ class DeviceRow(OrderedDict):
|
|||
software = "{software} {version}".format(
|
||||
software=snapshot.software.name, version=snapshot.version)
|
||||
# General information about device
|
||||
self['System ID'] = device.id
|
||||
self['DevicehubID'] = device.devicehub_id
|
||||
self['DocumentID'] = self.document_id
|
||||
self['Public Link'] = '{url}{id}'.format(url=url_for('Device.main', _external=True),
|
||||
id=device.id)
|
||||
id=device.devicehub_id)
|
||||
self['Tag 1 Type'] = self['Tag 1 ID'] = self['Tag 1 Organization'] = ''
|
||||
self['Tag 2 Type'] = self['Tag 2 ID'] = self['Tag 2 Organization'] = ''
|
||||
self['Tag 3 Type'] = self['Tag 3 ID'] = self['Tag 3 Organization'] = ''
|
||||
|
@ -370,7 +370,7 @@ class ActionRow(OrderedDict):
|
|||
def __init__(self, allocate):
|
||||
super().__init__()
|
||||
# General information about allocates, deallocate and lives
|
||||
self['SystemId'] = allocate['systemId']
|
||||
self['DevicehubID'] = allocate['devicehubID']
|
||||
self['Hid'] = allocate['hid']
|
||||
self['Start'] = allocate['start']
|
||||
self['FinalUserCode'] = allocate['finalUserCode']
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
|
||||
<dt>Computer where was erase:</dt>
|
||||
<dd>Title: {{ erasure.parent.__format__('ts') }}</dd>
|
||||
<dd>SystemId: {{ erasure.parent.id }}</dd>
|
||||
<dd>DevicehubID: {{ erasure.parent.devicehub_id }}</dd>
|
||||
<dd>Hid: {{ erasure.parent.hid }}</dd>
|
||||
<dd>Tags: {{ erasure.parent.tags }}</dd>
|
||||
|
||||
<dt>Computer where it resides:</dt>
|
||||
<dd>Title: {{ erasure.device.parent.__format__('ts') }}</dd>
|
||||
<dd>SystemId: {{ erasure.device.parent.id }}</dd>
|
||||
<dd>DevicehubID: {{ erasure.device.parent.devicehub_id }}</dd>
|
||||
<dd>Hid: {{ erasure.device.parent.hid }}</dd>
|
||||
<dd>Tags: {{ erasure.device.parent.tags }}</dd>
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ class TagDef(Resource):
|
|||
)
|
||||
super().__init__(app, import_name, static_folder, static_url_path, template_folder,
|
||||
url_prefix, subdomain, url_defaults, root_path, cli_commands)
|
||||
_get_device_from_tag = app.auth.requires_auth(get_device_from_tag)
|
||||
|
||||
# DeviceTagView URLs
|
||||
device_view = TagDeviceView.as_view('tag-device-view', definition=self, auth=app.auth)
|
||||
|
|
|
@ -66,8 +66,9 @@ class TagDeviceView(View):
|
|||
return app.resources[Device.t].schema.jsonify(tag.device)
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def put(self, tag_id: str, device_id: str):
|
||||
def put(self, tag_id: str, device_id: int):
|
||||
"""Links an existing tag with a device."""
|
||||
device_id = int(device_id)
|
||||
tag = Tag.from_an_id(tag_id).one() # type: Tag
|
||||
if tag.device_id:
|
||||
if tag.device_id == device_id:
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -242,7 +242,7 @@ def test_generic_action(action_model_state: Tuple[models.Action, states.Trading]
|
|||
action = {'type': action_model.t, 'devices': [snapshot['device']['id']]}
|
||||
action, _ = user.post(action, res=models.Action)
|
||||
assert action['devices'][0]['id'] == snapshot['device']['id']
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert device['actions'][-1]['id'] == action['id']
|
||||
assert device['physical'] == state.name
|
||||
# Check if the update of device is changed
|
||||
|
@ -625,6 +625,7 @@ def test_allocate(user: UserClient):
|
|||
""" Tests allocate """
|
||||
snapshot, _ = user.post(file('basic.snapshot'), res=models.Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
devicehub_id = snapshot['device']['devicehubID']
|
||||
post_request = {"transaction": "ccc",
|
||||
"finalUserCode": "aabbcc",
|
||||
"name": "John",
|
||||
|
@ -638,7 +639,7 @@ def test_allocate(user: UserClient):
|
|||
|
||||
allocate, _ = user.post(res=models.Allocate, data=post_request)
|
||||
# Normal allocate
|
||||
device, _ = user.get(res=Device, item=device_id)
|
||||
device, _ = user.get(res=Device, item=devicehub_id)
|
||||
assert device['allocated'] == True
|
||||
action = [a for a in device['actions'] if a['type'] == 'Allocate'][0]
|
||||
assert action['transaction'] == allocate['transaction']
|
||||
|
@ -691,6 +692,7 @@ def test_deallocate(user: UserClient):
|
|||
""" Tests deallocate """
|
||||
snapshot, _ = user.post(file('basic.snapshot'), res=models.Snapshot)
|
||||
device_id = snapshot['device']['id']
|
||||
devicehub_id = snapshot['device']['devicehubID']
|
||||
post_deallocate = {"startTime": "2020-11-01T02:00:00+00:00",
|
||||
"transaction": "ccc",
|
||||
"devices": [device_id]
|
||||
|
@ -705,7 +707,7 @@ def test_deallocate(user: UserClient):
|
|||
}
|
||||
|
||||
user.post(res=models.Allocate, data=post_allocate)
|
||||
device, _ = user.get(res=Device, item=device_id)
|
||||
device, _ = user.get(res=Device, item=devicehub_id)
|
||||
assert device['allocated'] == True
|
||||
deallocate, _ = user.post(res=models.Deallocate, data=post_deallocate)
|
||||
assert deallocate['startTime'] == post_deallocate['startTime']
|
||||
|
@ -762,7 +764,7 @@ def test_trade(action_model_state: Tuple[Type[models.Action], states.Trading], u
|
|||
action['invoiceNumber'] = 'ABC'
|
||||
action, _ = user.post(action, res=models.Action)
|
||||
assert action['devices'][0]['id'] == snapshot['device']['id']
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert device['actions'][-1]['id'] == action['id']
|
||||
assert device['trading'] == state.name
|
||||
|
||||
|
@ -785,7 +787,7 @@ def test_price_custom():
|
|||
assert p['price'] == 25.25
|
||||
assert p['currency'] == Currency.EUR.name == 'EUR'
|
||||
|
||||
c, _ = client.get(res=Device, item=computer.id)
|
||||
c, _ = client.get(res=Device, item=computer.devicehub_id)
|
||||
assert c['price']['id'] == p['id']
|
||||
|
||||
|
||||
|
@ -803,7 +805,7 @@ def test_price_custom_client(user: UserClient):
|
|||
assert 25 == price['price']
|
||||
assert Currency.EUR.name == price['currency']
|
||||
|
||||
device, _ = user.get(res=Device, item=price['device']['id'])
|
||||
device, _ = user.get(res=Device, item=price['device']['devicehubID'])
|
||||
assert 25 == device['price']['price']
|
||||
|
||||
|
||||
|
|
|
@ -416,7 +416,9 @@ def test_get_device(app: Devicehub, user: UserClient):
|
|||
agent=Person(name='Timmy'),
|
||||
author=User(email='bar@bar.com')))
|
||||
db.session.commit()
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
devicehub_id = pc.devicehub_id
|
||||
|
||||
pc, _ = user.get(res=d.Device, item=devicehub_id)
|
||||
assert len(pc['actions']) == 1
|
||||
assert pc['actions'][0]['type'] == 'TestConnectivity'
|
||||
assert pc['actions'][0]['device'] == 1
|
||||
|
@ -473,14 +475,14 @@ def test_get_device_permissions(app: Devicehub, user: UserClient, user2: UserCli
|
|||
"""Checks GETting a d.Desktop with its components."""
|
||||
|
||||
s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot)
|
||||
pc, res = user.get(res=d.Device, item=s['device']['id'])
|
||||
pc, res = user.get(res=d.Device, item=s['device']['devicehubID'])
|
||||
assert res.status_code == 200
|
||||
assert len(pc['actions']) == 9
|
||||
|
||||
html, _ = client.get(res=d.Device, item=s['device']['id'], accept=ANY)
|
||||
html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY)
|
||||
assert 'intel atom cpu n270 @ 1.60ghz' in html
|
||||
assert '00:24:8C:7F:CF:2D – 100 Mbps' in html
|
||||
pc2, res2 = user2.get(res=d.Device, item=s['device']['id'], accept=ANY)
|
||||
pc2, res2 = user2.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY)
|
||||
assert res2.status_code == 200
|
||||
assert pc2 == html
|
||||
|
||||
|
@ -555,7 +557,7 @@ def test_device_properties_format(app: Devicehub, user: UserClient):
|
|||
@pytest.mark.mvp
|
||||
def test_device_public(user: UserClient, client: Client):
|
||||
s, _ = user.post(file('asus-eee-1000h.snapshot.11'), res=m.Snapshot)
|
||||
html, _ = client.get(res=d.Device, item=s['device']['id'], accept=ANY)
|
||||
html, _ = client.get(res=d.Device, item=s['device']['devicehubID'], accept=ANY)
|
||||
assert 'intel atom cpu n270 @ 1.60ghz' in html
|
||||
assert '00:24:8C:7F:CF:2D – 100 Mbps' in html
|
||||
|
||||
|
@ -614,8 +616,8 @@ def test_cooking_mixer_api(user: UserClient):
|
|||
def test_hid_with_mac(app: Devicehub, user: UserClient):
|
||||
"""Checks hid with mac."""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
snap, _ = user.post(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'
|
||||
|
||||
|
||||
|
@ -624,8 +626,8 @@ def test_hid_without_mac(app: Devicehub, user: UserClient):
|
|||
"""Checks hid without mac."""
|
||||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
snapshot['components'] = [c for c in snapshot['components'] if c['type'] != 'NetworkAdapter']
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||
|
||||
|
||||
|
@ -635,8 +637,8 @@ def test_hid_with_mac_none(app: Devicehub, user: UserClient):
|
|||
snapshot = file('asus-eee-1000h.snapshot.11')
|
||||
network = [c for c in snapshot['components'] if c['type'] == 'NetworkAdapter'][0]
|
||||
network['serialNumber'] = None
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
snap, _ = user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=snap['device']['devicehubID'])
|
||||
assert pc['hid'] == 'laptop-asustek_computer_inc-1000h-94oaaq021116'
|
||||
|
||||
|
||||
|
@ -664,8 +666,8 @@ def test_hid_with_2network_and_drop_no_mac_in_hid(app: Devicehub, user: UserClie
|
|||
network2 = copy.copy(network)
|
||||
snapshot['components'].append(network2)
|
||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
snap, _ = user.post(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'
|
||||
|
@ -687,8 +689,8 @@ def test_hid_with_2network_and_drop_mac_in_hid(app: Devicehub, user: UserClient)
|
|||
network2 = copy.copy(network)
|
||||
snapshot['components'].append(network2)
|
||||
network['serialNumber'] = 'a0:24:8c:7f:cf:2d'
|
||||
user.post(snapshot, res=m.Snapshot)
|
||||
pc, _ = user.get(res=d.Device, item=1)
|
||||
snap, _ = user.post(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
|
||||
|
|
|
@ -173,7 +173,7 @@ def test_live_export_csv2(user: UserClient, client: Client, app: Devicehub):
|
|||
|
||||
assert "4692" in csv_user
|
||||
assert "8692" in csv_user
|
||||
assert "SystemId" in csv_user
|
||||
assert "DevicehubID" in csv_user
|
||||
|
||||
@pytest.mark.mvp
|
||||
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||
|
|
|
@ -365,13 +365,14 @@ def test_lot_post_add_remove_device_view(app: Devicehub, user: UserClient):
|
|||
db.session.add(device)
|
||||
db.session.commit()
|
||||
device_id = device.id
|
||||
devicehub_id = device.devicehub_id
|
||||
parent, _ = user.post(({'name': 'lot'}), res=Lot)
|
||||
lot, _ = user.post({},
|
||||
res=Lot,
|
||||
item='{}/devices'.format(parent['id']),
|
||||
query=[('id', device_id)])
|
||||
assert lot['devices'][0]['id'] == device_id, 'Lot contains device'
|
||||
device, _ = user.get(res=Device, item=device_id)
|
||||
device, _ = user.get(res=Device, item=devicehub_id)
|
||||
assert len(device['lots']) == 1
|
||||
assert device['lots'][0]['id'] == lot['id'], 'Device is inside lot'
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ def test_rate_with_multiple_visual_tests(user: UserClient):
|
|||
"""
|
||||
s = file('real-hp.snapshot.11')
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
visual_test = next(e for e in reversed(device['actions']) if e['type'] == VisualTest.t)
|
||||
|
||||
assert visual_test['appearanceRange'] == 'B'
|
||||
|
@ -53,7 +53,7 @@ def test_rate_with_multiple_visual_tests(user: UserClient):
|
|||
'appearanceRange': 'A',
|
||||
'functionalityRange': 'A'
|
||||
}, res=Action)
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
visual_test = next(e for e in reversed(device['actions']) if e['type'] == VisualTest.t)
|
||||
|
||||
assert visual_test['appearanceRange'] == 'A'
|
||||
|
|
|
@ -92,7 +92,7 @@ def test_snapshot_post(user: UserClient):
|
|||
assert snapshot['author']['id'] == user.user['id']
|
||||
assert 'actions' not in snapshot['device']
|
||||
assert 'author' not in snapshot['device']
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
key = itemgetter('serialNumber')
|
||||
snapshot['components'].sort(key=key)
|
||||
device['components'].sort(key=key)
|
||||
|
@ -140,8 +140,8 @@ def test_snapshot_update_timefield_updated(user: UserClient):
|
|||
computer2 = file('2-second-device-with-components-of-first.snapshot')
|
||||
snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'),
|
||||
perform_second_snapshot=False)
|
||||
pc1_id = snapshot['device']['id']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_id)
|
||||
pc1_devicehub_id = snapshot['device']['devicehubID']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
assert pc1['updated'] != snapshot['device']['updated']
|
||||
|
||||
|
||||
|
@ -170,7 +170,8 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
RateComputer.t),
|
||||
perform_second_snapshot=False)
|
||||
pc1_id = snapshot1['device']['id']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_id)
|
||||
pc1_devicehub_id = snapshot1['device']['devicehubID']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
update1_pc1 = pc1['updated']
|
||||
# Parent contains components
|
||||
assert tuple(c['serialNumber'] for c in pc1['components']) == ('p1c1s', 'p1c2s', 'p1c3s')
|
||||
|
@ -180,7 +181,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
assert len(pc1['actions']) == 3
|
||||
assert pc1['actions'][1]['type'] == Snapshot.t
|
||||
# p1c1s has Snapshot
|
||||
p1c1s, _ = user.get(res=m.Device, item=pc1['components'][0]['id'])
|
||||
p1c1s, _ = user.get(res=m.Device, item=pc1['components'][0]['devicehubID'])
|
||||
assert tuple(e['type'] for e in p1c1s['actions']) == ('Snapshot', 'RateComputer')
|
||||
|
||||
# We register a new device
|
||||
|
@ -192,8 +193,9 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
snapshot2 = snapshot_and_check(user, s2, action_types=('Remove', 'RateComputer'),
|
||||
perform_second_snapshot=False)
|
||||
pc2_id = snapshot2['device']['id']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_id)
|
||||
pc2_devicehub_id = snapshot2['device']['devicehubID']
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
|
||||
# Check if the update_timestamp is updated
|
||||
update1_pc2 = pc2['updated']
|
||||
update2_pc1 = pc1['updated']
|
||||
|
@ -207,7 +209,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
assert all(c['parent'] == pc2_id for c in pc2['components'])
|
||||
assert tuple(e['type'] for e in pc2['actions']) == ('Snapshot', 'RateComputer')
|
||||
# p1c2s has two Snapshots, a Remove and an Add
|
||||
p1c2s, _ = user.get(res=m.Device, item=pc2['components'][0]['id'])
|
||||
p1c2s, _ = user.get(res=m.Device, item=pc2['components'][0]['devicehubID'])
|
||||
assert tuple(e['type'] for e in p1c2s['actions']) == (
|
||||
'BenchmarkProcessor', 'Snapshot', 'RateComputer', 'Snapshot', 'Remove', 'RateComputer'
|
||||
)
|
||||
|
@ -218,8 +220,8 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# PC 0: p1c2s, p1c3s. PC 1: p2c1s
|
||||
s3 = file('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_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_id)
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
|
||||
# Check if the update_timestamp is updated
|
||||
update2_pc2 = pc2['updated']
|
||||
update3_pc1 = pc1['updated']
|
||||
|
@ -247,7 +249,7 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
'Remove' # the processor we added in 2.
|
||||
)
|
||||
# p1c2s has Snapshot, Remove and Add
|
||||
p1c2s, _ = user.get(res=m.Device, item=pc1['components'][0]['id'])
|
||||
p1c2s, _ = user.get(res=m.Device, item=pc1['components'][0]['devicehubID'])
|
||||
assert tuple(get_actions_info(p1c2s['actions'])) == (
|
||||
('BenchmarkProcessor', []), # first BenchmarkProcessor
|
||||
('Snapshot', ['p1c1s', 'p1c2s', 'p1c3s']), # First Snapshot to PC1
|
||||
|
@ -264,8 +266,8 @@ def test_snapshot_component_add_remove(user: UserClient):
|
|||
# adding a graphic card and adding a new component
|
||||
s4 = file('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_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_id)
|
||||
pc1, _ = user.get(res=m.Device, item=pc1_devicehub_id)
|
||||
pc2, _ = user.get(res=m.Device, item=pc2_devicehub_id)
|
||||
# Check if the update_timestamp is updated
|
||||
update3_pc2 = pc2['updated']
|
||||
update4_pc1 = pc1['updated']
|
||||
|
@ -429,7 +431,7 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient):
|
|||
|
||||
# The actual test
|
||||
storage = next(e for e in snapshot['components'] if e['type'] == SolidStateDrive.t)
|
||||
storage, _ = user.get(res=m.Device, item=storage['id']) # Let's get storage actions too
|
||||
storage, _ = user.get(res=m.Device, item=storage['devicehubID']) # Let's get storage actions too
|
||||
# order: endTime ascending
|
||||
# erasure1/2 have an user defined time and others actions endTime = created
|
||||
erasure1, erasure2, benchmark_hdd1, _snapshot1, _, _, benchmark_hdd2, _snapshot2 = storage['actions'][:8]
|
||||
|
@ -455,17 +457,17 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient):
|
|||
assert 'num' not in step2
|
||||
assert ['HMG_IS5'] == erasure['standards']
|
||||
assert storage['privacy']['type'] == 'EraseSectors'
|
||||
pc, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
pc, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
assert pc['privacy'] == [storage['privacy']]
|
||||
|
||||
# Let's try a second erasure with an error
|
||||
s['uuid'] = uuid4()
|
||||
s['components'][0]['actions'][0]['severity'] = 'Error'
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
storage, _ = user.get(res=m.Device, item=storage['id'])
|
||||
storage, _ = user.get(res=m.Device, item=storage['devicehubID'])
|
||||
assert storage['hid'] == 'solidstatedrive-c1mr-c1ml-c1s'
|
||||
assert storage['privacy']['type'] == 'EraseSectors'
|
||||
pc, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
pc, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
assert pc['privacy'] == [storage['privacy']]
|
||||
|
||||
|
||||
|
@ -780,7 +782,7 @@ def test_snapshot_failed_end_time_bug(app: Devicehub, user: UserClient):
|
|||
"""
|
||||
snapshot_file = file('asus-end_time_bug88.snapshot')
|
||||
snapshot, _ = user.post(res=Snapshot, data=snapshot_file)
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
end_times = [x['endTime'] for x in device['actions']]
|
||||
|
||||
assert '1970-01-02T00:00:00+00:00' in end_times
|
||||
|
@ -797,7 +799,7 @@ def test_snapshot_not_failed_end_time_bug(app: Devicehub, user: UserClient):
|
|||
snapshot_file = file('asus-end_time_bug88.snapshot')
|
||||
snapshot_file['endTime'] = '2001-01-01 00:00:00+00:00'
|
||||
snapshot, _ = user.post(res=Snapshot, data=snapshot_file)
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
end_times = [x['endTime'] for x in device['actions']]
|
||||
|
||||
assert not '1970-01-02T00:00:00+00:00' in end_times
|
||||
|
@ -831,7 +833,7 @@ def test_snapshot_mobil(app: Devicehub, user: UserClient):
|
|||
"""
|
||||
snapshot_file = file('mobil')
|
||||
snapshot, _ = user.post(res=Snapshot, data=snapshot_file)
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=m.Device, item=snapshot['device']['devicehubID'])
|
||||
|
||||
tmp_snapshots = app.config['TMP_SNAPSHOTS']
|
||||
shutil.rmtree(tmp_snapshots)
|
||||
|
|
|
@ -183,8 +183,9 @@ def test_tag_manual_link_search(app: Devicehub, user: UserClient):
|
|||
db.session.add(desktop)
|
||||
db.session.commit()
|
||||
desktop_id = desktop.id
|
||||
devicehub_id = desktop.devicehub_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=devicehub_id)
|
||||
assert device['tags'][0]['id'] == 'foo-bar'
|
||||
|
||||
# Device already linked
|
||||
|
@ -224,7 +225,7 @@ def test_tag_secondary_workbench_link_find(user: UserClient):
|
|||
s = file('basic.snapshot')
|
||||
s['device']['tags'] = [{'id': 'foo', 'secondary': 'bar', 'type': 'Tag'}]
|
||||
snapshot, _ = user.post(s, res=Snapshot)
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert device['tags'][0]['id'] == 'foo'
|
||||
assert device['tags'][0]['secondary'] == 'bar'
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ def test_workbench_server_condensed(user: UserClient):
|
|||
}
|
||||
assert snapshot['closed']
|
||||
assert snapshot['severity'] == 'Info'
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
device, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert device['dataStorageSize'] == 1100
|
||||
assert device['chassis'] == 'Tower'
|
||||
assert device['hid'] == 'desktop-d1mr-d1ml-d1s-na1-s'
|
||||
|
@ -129,7 +129,7 @@ def test_workbench_server_phases(user: UserClient):
|
|||
assert snapshot['closed']
|
||||
assert snapshot['severity'] == 'Info'
|
||||
|
||||
pc, _ = user.get(res=Device, item=snapshot['id'])
|
||||
pc, _ = user.get(res=Device, item=snapshot['devicehubID'])
|
||||
assert len(pc['actions']) == 10 # todo shall I add child actions?
|
||||
|
||||
|
||||
|
@ -173,7 +173,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
|
|||
"""
|
||||
s = file('real-eee-1001pxd.snapshot.11')
|
||||
snapshot, _ = user.post(res=em.Snapshot, data=s)
|
||||
pc, _ = user.get(res=Device, item=snapshot['device']['id'])
|
||||
pc, _ = user.get(res=Device, item=snapshot['device']['devicehubID'])
|
||||
assert pc['type'] == 'Laptop'
|
||||
assert pc['chassis'] == 'Netbook'
|
||||
assert pc['model'] == '1001pxd'
|
||||
|
@ -213,7 +213,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
|
|||
assert cpu['speed'] == 1.667
|
||||
assert 'hid' not in cpu
|
||||
assert pc['processorModel'] == cpu['model'] == 'intel atom cpu n455 @ 1.66ghz'
|
||||
cpu, _ = user.get(res=Device, item=cpu['id'])
|
||||
cpu, _ = user.get(res=Device, item=cpu['devicehubID'])
|
||||
actions = cpu['actions']
|
||||
sysbench = next(e for e in actions if e['type'] == em.BenchmarkProcessorSysbench.t)
|
||||
assert sysbench['elapsed'] == 164
|
||||
|
@ -233,7 +233,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
|
|||
assert gpu['model'] == 'atom processor d4xx/d5xx/n4xx/n5xx integrated graphics controller'
|
||||
assert gpu['manufacturer'] == 'intel corporation'
|
||||
assert gpu['memory'] == 256
|
||||
gpu, _ = user.get(res=Device, item=gpu['id'])
|
||||
gpu, _ = user.get(res=Device, item=gpu['devicehubID'])
|
||||
action_types = tuple(e['type'] for e in gpu['actions'])
|
||||
assert em.BenchmarkRamSysbench.t in action_types
|
||||
assert em.StressTest.t in action_types
|
||||
|
@ -252,7 +252,7 @@ def test_snapshot_real_eee_1001pxd_with_rate(user: UserClient):
|
|||
assert hdd['hid'] == 'harddrive-hitachi-hts54322-e2024242cv86hj'
|
||||
assert hdd['interface'] == 'ATA'
|
||||
assert hdd['size'] == 238475
|
||||
hdd, _ = user.get(res=Device, item=hdd['id'])
|
||||
hdd, _ = user.get(res=Device, item=hdd['devicehubID'])
|
||||
action_types = tuple(e['type'] for e in hdd['actions'])
|
||||
assert em.BenchmarkRamSysbench.t in action_types
|
||||
assert em.StressTest.t in action_types
|
||||
|
|
Reference in New Issue