From 302fa23669bf4f79c4e3b11271463709ec863250 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Thu, 21 Nov 2024 21:40:22 -0800 Subject: [PATCH 1/3] fix python dependencies --- apps/api/requirements-dev.txt | 14 +++++++------- apps/api/requirements.txt | 15 ++++++--------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/api/requirements-dev.txt b/apps/api/requirements-dev.txt index 939520ed..e9769257 100644 --- a/apps/api/requirements-dev.txt +++ b/apps/api/requirements-dev.txt @@ -1,10 +1,10 @@ -black==23.11.0 -flake8==6.1.0 -mypy==1.7.1 -pytest==7.4.3 -pytest-asyncio==0.23.2 -pytest-cov==4.1.0 +black==24.10.0 +flake8==7.1.0 +mypy==1.13.0 +pytest==8.3.3 +pytest-asyncio==0.24.0 +pytest-cov==6.0.0 types-python-jose==3.3.4.8 -uvicorn[standard]==0.23.2 +uvicorn[standard]==0.32.0 diff --git a/apps/api/requirements.txt b/apps/api/requirements.txt index b6734458..a7c40939 100644 --- a/apps/api/requirements.txt +++ b/apps/api/requirements.txt @@ -1,13 +1,10 @@ -fastapi==0.104.1 -httpx==0.25.2 -python-multipart==0.0.5 +fastapi==0.115.5 +httpx==0.27.2 +python-multipart==0.0.12 python3-saml==1.16.0 python-jose[cryptography]==3.3.0 -motor==3.3.2 -pydantic[email]==2.5.2 +motor==3.6.0 +pydantic[email]==2.9.2 aiosendgrid==0.1.0 sendgrid==6.11.0 -aiogoogle==5.6.0 - -# To avoid breaking xmlsec for python3-saml -lxml<5.0.0 +aiogoogle==5.13.2 From bc4845aeaa46986b312cb18a9d2458498e52a88c Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sat, 23 Nov 2024 18:29:25 -0800 Subject: [PATCH 2/3] update pytests and adjusted package versions accordingly --- apps/api/requirements.txt | 6 +++--- apps/api/tests/test_guest_auth.py | 4 ++-- apps/api/tests/test_user_apply.py | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/api/requirements.txt b/apps/api/requirements.txt index a7c40939..a99d9c16 100644 --- a/apps/api/requirements.txt +++ b/apps/api/requirements.txt @@ -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 diff --git a/apps/api/tests/test_guest_auth.py b/apps/api/tests/test_guest_auth.py index 328ccab6..2765d531 100644 --- a/apps/api/tests/test_guest_auth.py +++ b/apps/api/tests/test_guest_auth.py @@ -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"} diff --git a/apps/api/tests/test_user_apply.py b/apps/api/tests/test_user_apply.py index e466dc60..914531af 100644 --- a/apps/api/tests/test_user_apply.py +++ b/apps/api/tests/test_user_apply.py @@ -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 = "pkfire@uci.edu" @@ -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( @@ -88,6 +88,7 @@ @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) @@ -95,6 +96,7 @@ 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: @@ -102,6 +104,7 @@ def test_apply_successfully( 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( From 5313e13aee7fbf9ffe0eeb47555c06fe5521ddfb Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sat, 23 Nov 2024 18:38:44 -0800 Subject: [PATCH 3/3] format Python --- apps/api/tests/test_guest_auth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/tests/test_guest_auth.py b/apps/api/tests/test_guest_auth.py index 2765d531..dc2c4c3c 100644 --- a/apps/api/tests/test_guest_auth.py +++ b/apps/api/tests/test_guest_auth.py @@ -42,7 +42,9 @@ def test_can_validate_key() -> None: 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(2024, 1, 11) - exp = datetime(2025, 7, 1, tzinfo=timezone.utc) # update expire date for this test to not fail :) + 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"}