Merge pull request #359 from eReuse/bugfix/3821-dhid_bk

fix dhid_bk
This commit is contained in:
cayop 2022-09-22 10:49:34 +02:00 committed by GitHub
commit 4c3851cbbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
# workbench device
if self.abstract_device:
self.abstract_device.dhid_bk = self.abstract_dhid
self.abstract_device.phid_bk = self.abstract_phid

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