diff --git a/ereuse_devicehub/resources/tradedocument/models.py b/ereuse_devicehub/resources/tradedocument/models.py index 7f211637..07af62d1 100644 --- a/ereuse_devicehub/resources/tradedocument/models.py +++ b/ereuse_devicehub/resources/tradedocument/models.py @@ -172,7 +172,9 @@ class TradeDocument(Thing): return sorted(ev for ev in actions if ev.severity >= Severity.Warning) def __lt__(self, other): - return self.id < other.id + if self.id and other.id: + return self.id < other.id + return False def __str__(self) -> str: return '{0.file_name}'.format(self) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index fbd437d9..f9f2299e 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2470,6 +2470,7 @@ def test_bug_3831_documents(user3: UserClientFlask): assert 'Delete Lot' in body assert 'Incoming Lot' in body + lot_id = Lot.query.all()[1].id uri = f'/inventory/lot/{lot_id}/trade-document/add/' body, status = user3.get(uri) @@ -2487,8 +2488,16 @@ def test_bug_3831_documents(user3: UserClientFlask): } uri = f'/inventory/lot/{lot_id}/trade-document/add/' - # body, status = user3.post(uri, data=data, content_type="multipart/form-data") - # assert status == '200 OK' + body, status = user3.post(uri, data=data, content_type="multipart/form-data") + assert status == '200 OK' + + # Second document + uri = f'/inventory/lot/{lot_id}/trade-document/add/' + file_upload = (BytesIO(b_file), file_name) + data['file'] = file_upload + data['csrf_token'] = generate_csrf() + body, status = user3.post(uri, data=data, content_type="multipart/form-data") + assert status == '200 OK' @pytest.mark.mvp