Skip to content

Commit

Permalink
Fix Python Dependencies (#384)
Browse files Browse the repository at this point in the history
* fix python dependencies

* update pytests and adjusted package versions accordingly

* format Python
  • Loading branch information
waalbert authored Nov 24, 2024
1 parent d529f55 commit 2fa0d03
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
14 changes: 7 additions & 7 deletions apps/api/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
13 changes: 5 additions & 8 deletions apps/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
fastapi==0.104.1
httpx==0.25.2
python-multipart==0.0.5
fastapi==0.113.0
httpx==0.27.2
python-multipart==0.0.17
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
6 changes: 4 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,10 @@ 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 2fa0d03

Please sign in to comment.