Skip to content

Commit

Permalink
update pytests and adjusted package versions accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
waalbert committed Nov 24, 2024
1 parent 302fa23 commit bc4845a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apps/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
fastapi==0.115.5
fastapi==0.113.0
httpx==0.27.2
python-multipart==0.0.12
python-multipart==0.0.17
python3-saml==1.16.0
python-jose[cryptography]==3.3.0
motor==3.6.0
pydantic[email]==2.9.2
aiosendgrid==0.1.0
sendgrid==6.11.0
aiogoogle==5.13.2
aiogoogle==5.6.0
4 changes: 2 additions & 2 deletions apps/api/tests/test_guest_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_can_validate_key() -> None:
@patch("services.mongodb_handler.retrieve_one", autospec=True)
async def test_get_existing_unexpired_key(mock_mongodb_retrieve_one: AsyncMock) -> None:
"""Test that existing, unexpired guest authorization key can be retrieved."""
iat = datetime(2023, 1, 11)
exp = datetime(2024, 7, 1, tzinfo=timezone.utc)
iat = datetime(2024, 1, 11)
exp = datetime(2025, 7, 1, tzinfo=timezone.utc) # update expire date for this test to not fail :)
# this test will fail next year :P
mock_mongodb_retrieve_one.return_value = {
"guest_auth": {"iat": iat, "exp": exp, "key": "some-key"}
Expand Down
7 changes: 5 additions & 2 deletions apps/api/tests/test_user_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from utils.user_record import Applicant, Status

# Tests will break again next year, tech should notice and fix :P
TEST_DEADLINE = datetime(2024, 10, 1, 8, 0, 0, tzinfo=timezone.utc)
TEST_DEADLINE = datetime(2025, 10, 1, 8, 0, 0, tzinfo=timezone.utc)
user.DEADLINE = TEST_DEADLINE

USER_EMAIL = "[email protected]"
Expand Down Expand Up @@ -49,7 +49,7 @@

EXPECTED_RESUME_UPLOAD = ("pk-fire-69f2afc2.pdf", b"resume", "application/pdf")
SAMPLE_RESUME_URL = HttpUrl("https://drive.google.com/file/d/...")
SAMPLE_SUBMISSION_TIME = datetime(2023, 1, 12, 8, 1, 21, tzinfo=timezone.utc)
SAMPLE_SUBMISSION_TIME = datetime(2024, 1, 12, 8, 1, 21, tzinfo=timezone.utc)
SAMPLE_VERDICT_TIME = None

EXPECTED_APPLICATION_DATA = ProcessedApplicationData(
Expand Down Expand Up @@ -88,20 +88,23 @@

@patch("utils.email_handler.send_application_confirmation_email", autospec=True)
@patch("services.mongodb_handler.update_one", autospec=True)
@patch("routers.user._is_past_deadline", autospec=True)
@patch("routers.user.datetime", autospec=True)
@patch("services.gdrive_handler.upload_file", autospec=True)
@patch("services.mongodb_handler.retrieve_one", autospec=True)
def test_apply_successfully(
mock_mongodb_handler_retrieve_one: AsyncMock,
mock_gdrive_handler_upload_file: AsyncMock,
mock_datetime: Mock,
mock_is_past_deadline: Mock,
mock_mongodb_handler_update_one: AsyncMock,
mock_send_application_confirmation_email: AsyncMock,
) -> None:
"""Test that a valid application is submitted properly."""
mock_mongodb_handler_retrieve_one.return_value = None
mock_gdrive_handler_upload_file.return_value = SAMPLE_RESUME_URL
mock_datetime.now.return_value = SAMPLE_SUBMISSION_TIME
mock_is_past_deadline.return_value = False
res = client.post("/apply", data=SAMPLE_APPLICATION, files=SAMPLE_FILES)

mock_gdrive_handler_upload_file.assert_awaited_once_with(
Expand Down

0 comments on commit bc4845a

Please sign in to comment.