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,8 +299,9 @@ class BindingView(GenericMixin):
# to do a backup of abstract_dhid and abstract_phid in
# workbench device
self.abstract_device.dhid_bk = self.abstract_dhid
self.abstract_device.phid_bk = self.abstract_phid
if self.abstract_device:
self.abstract_device.dhid_bk = self.abstract_dhid
self.abstract_device.phid_bk = self.abstract_phid
def post(self):
for plog in PlaceholdersLog.query.filter_by(

View file

@ -2339,3 +2339,32 @@ def test_list_erasures(user3: UserClientFlask):
txt = "WD-WCAV27984668"
assert status == '200 OK'
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