fix dhid_bk

This commit is contained in:
Cayo Puigdefabregas 2022-09-22 10:15:37 +02:00
parent 553f85776a
commit 0f6364f075
2 changed files with 32 additions and 2 deletions

View File

@ -299,6 +299,7 @@ class BindingView(GenericMixin):
# to do a backup of abstract_dhid and abstract_phid in # to do a backup of abstract_dhid and abstract_phid in
# workbench device # workbench device
if self.abstract_device:
self.abstract_device.dhid_bk = self.abstract_dhid self.abstract_device.dhid_bk = self.abstract_dhid
self.abstract_device.phid_bk = self.abstract_phid self.abstract_device.phid_bk = self.abstract_phid

View File

@ -2339,3 +2339,32 @@ def test_list_erasures(user3: UserClientFlask):
txt = "WD-WCAV27984668" txt = "WD-WCAV27984668"
assert status == '200 OK' assert status == '200 OK'
assert txt in body assert txt in body
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_bug_3821_binding(user3: UserClientFlask):
uri = '/inventory/device/add/'
user3.get(uri)
data = {
'csrf_token': generate_csrf(),
'type': "Laptop",
'phid': 'sid',
'serial_number': "AAAAB",
'model': "LC27T55",
'manufacturer': "Samsung",
'generation': 1,
'weight': 0.1,
'height': 0.1,
'depth': 0.1,
'id_device_supplier': "b2",
}
user3.post(uri, data=data)
dev = Device.query.one()
dhid = dev.dhid
assert dev.phid() == 'sid'
uri = f'/inventory/binding/{dhid}/sid/'
body, status = user3.get(uri)
assert status == '200 OK'
assert 'is not a Snapshot device!' in body