Skip to content

Commit

Permalink
Add some more e2e tests #11
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Sep 26, 2024
1 parent 9b389c3 commit c54a6fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/e2e/test_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
7 changes: 7 additions & 0 deletions test/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit c54a6fc

Please sign in to comment.