From b1ad7b151d763b24c99adafdf09215694b476b9e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 10:23:51 +0100 Subject: [PATCH 1/2] fix orther without id --- ereuse_devicehub/resources/tradedocument/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) From 9fbdaf583444bb8f7120165860edb60535e55efc Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 30 Nov 2022 10:59:56 +0100 Subject: [PATCH 2/2] add test --- tests/test_render_2_0.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index f9f82928..74f57c1f 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2454,6 +2454,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) @@ -2471,8 +2472,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