From c54a6fcb4fe8a600388c7704bf04fc687ee31de9 Mon Sep 17 00:00:00 2001 From: Joel Davies Date: Thu, 26 Sep 2024 08:00:58 +0000 Subject: [PATCH] Add some more e2e tests #11 --- test/e2e/test_attachment.py | 21 ++++++++++++++++++++- test/mock_data.py | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/test/e2e/test_attachment.py b/test/e2e/test_attachment.py index c64cab0..0a2bdc0 100644 --- a/test/e2e/test_attachment.py +++ b/test/e2e/test_attachment.py @@ -2,7 +2,12 @@ End-to-End tests for the attachment router. """ -from test.mock_data import ATTACHMENT_POST_DATA_REQUIRED_VALUES_ONLY, ATTACHMENT_POST_RESPONSE_DATA_REQUIRED_VALUES_ONLY +from test.mock_data import ( + ATTACHMENT_POST_DATA_ALL_VALUES, + ATTACHMENT_POST_DATA_REQUIRED_VALUES_ONLY, + ATTACHMENT_POST_RESPONSE_DATA_ALL_VALUES, + ATTACHMENT_POST_RESPONSE_DATA_REQUIRED_VALUES_ONLY, +) from typing import Optional import pytest @@ -91,3 +96,17 @@ def test_create_with_only_required_values_provided(self): self.check_post_attachment_success(ATTACHMENT_POST_RESPONSE_DATA_REQUIRED_VALUES_ONLY) self.upload_attachment() self.check_upload_attachment_success() + + def test_create_with_all_values_provided(self): + """Test creating an attachment with all values provided.""" + + self.post_attachment(ATTACHMENT_POST_DATA_ALL_VALUES) + self.check_post_attachment_success(ATTACHMENT_POST_RESPONSE_DATA_ALL_VALUES) + self.upload_attachment() + self.check_upload_attachment_success() + + def test_create_with_invalid_entity_id(self): + """Test creating an attachment with an invalid `entity_id`.""" + + self.post_attachment({**ATTACHMENT_POST_DATA_REQUIRED_VALUES_ONLY, "entity_id": "invalid-id"}) + self.check_post_attachment_failed_with_detail(422, "Invalid `entity_id` given") diff --git a/test/mock_data.py b/test/mock_data.py index deeaf77..4c2f27b 100644 --- a/test/mock_data.py +++ b/test/mock_data.py @@ -52,3 +52,10 @@ "id": str(ObjectId()), "object_key": "attachments/65df5ee771892ddcc08bd28f/65e0a624d64aaae884abaaee", } + +ATTACHMENT_POST_RESPONSE_DATA_ALL_VALUES = { + **ATTACHMENT_POST_DATA_ALL_VALUES, + **CREATED_MODIFIED_GET_DATA_EXPECTED, + "id": ANY, + "upload_url": ANY, +}