Skip to content

Commit

Permalink
chore: upgrade python to 3.10.13 (#1490)
Browse files Browse the repository at this point in the history
* chore: upgrade python to 3.10.13

* fix: updating version in CI

* fix: updating lock file

* style: reformatted with black

* fix: used mocker instead of a dummy fn and corrected spelling of fake
  • Loading branch information
Anas12091101 authored Mar 20, 2024
1 parent 36498af commit ce9f9d5
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9.13"
python-version: "3.10.13"

- id: cache
uses: actions/cache@v1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.13
FROM python:3.10.13
LABEL maintainer "ODL DevOps <[email protected]>"


Expand Down
12 changes: 6 additions & 6 deletions authentication/middleware_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
from authentication.middleware import SocialAuthExceptionRedirectMiddleware


def test_process_exception_no_strategy(rf, settings):
def test_process_exception_no_strategy(mocker, rf, settings):
"""Tests that if the request has no strategy it does nothing"""
settings.DEBUG = False
request = rf.get(reverse("social:complete", args=("email",)))
middleware = SocialAuthExceptionRedirectMiddleware()
middleware = SocialAuthExceptionRedirectMiddleware(get_response=mocker.Mock())
assert middleware.process_exception(request, None) is None


def test_process_exception(rf, settings):
def test_process_exception(mocker, rf, settings):
"""Tests that a process_exception handles auth exceptions correctly"""
settings.DEBUG = False
request = rf.get(reverse("social:complete", args=("email",)))
Expand All @@ -28,7 +28,7 @@ def test_process_exception(rf, settings):
request.social_strategy = strategy
request.backend = backend

middleware = SocialAuthExceptionRedirectMiddleware()
middleware = SocialAuthExceptionRedirectMiddleware(get_response=mocker.Mock())
error = AuthAlreadyAssociated(backend)
result = middleware.process_exception(request, error)
assert result.status_code == status.HTTP_302_FOUND
Expand All @@ -37,7 +37,7 @@ def test_process_exception(rf, settings):
)


def test_process_exception_non_auth_error(rf, settings):
def test_process_exception_non_auth_error(mocker, rf, settings):
"""Tests that a process_exception handles non-auth exceptions correctly"""
settings.DEBUG = False
request = rf.get(reverse("social:complete", args=("email",)))
Expand All @@ -48,7 +48,7 @@ def test_process_exception_non_auth_error(rf, settings):
request.social_strategy = strategy
request.backend = backend

middleware = SocialAuthExceptionRedirectMiddleware()
middleware = SocialAuthExceptionRedirectMiddleware(get_response=mocker.Mock())
assert (
middleware.process_exception(request, Exception("something bad happened"))
is None
Expand Down
51 changes: 31 additions & 20 deletions authentication/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ def noop():
@contextmanager
def export_check_response(response_name):
"""Context manager for configuring export check responses"""
with override_settings(
**get_cybersource_test_settings()
), responses.RequestsMock() as mocked_responses:
with (
override_settings(**get_cybersource_test_settings()),
responses.RequestsMock() as mocked_responses,
):
mock_cybersource_wsdl(mocked_responses, settings)
mock_cybersource_wsdl_operation(mocked_responses, response_name)
yield
Expand Down Expand Up @@ -272,14 +273,15 @@ def register_email_exists(self, recaptcha_enabled):
def register_email_not_exists_with_recaptcha_invalid(self):
"""Yield a function for this step"""
self.flow_started = True
with patch(
"authentication.views.requests.post",
return_value=MockResponse(
content='{"success": false, "error-codes": ["bad-request"]}',
status_code=status.HTTP_200_OK,
),
) as mock_recaptcha_failure, override_settings(
**{"RECAPTCHA_SITE_KEY": "fakse"}
with (
patch(
"authentication.views.requests.post",
return_value=MockResponse(
content='{"success": false, "error-codes": ["bad-request"]}',
status_code=status.HTTP_200_OK,
),
) as mock_recaptcha_failure,
override_settings(**{"RECAPTCHA_SITE_KEY": "fake"}),
):
assert_api_call(
self.client,
Expand Down Expand Up @@ -455,9 +457,12 @@ def login_password_user_inactive(self, auth_state, verify_exports):
@rule(auth_state=consumes(LoginPasswordAuthStates))
def login_password_exports_temporary_error(self, auth_state):
"""Login for a user who hasn't been OFAC verified yet"""
with override_settings(**get_cybersource_test_settings()), patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
with (
override_settings(**get_cybersource_test_settings()),
patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
),
):
assert_api_call(
self.client,
Expand Down Expand Up @@ -632,9 +637,12 @@ def register_details_export_reject(self, auth_state):
@rule(auth_state=consumes(ConfirmationRedeemedAuthStates))
def register_details_export_temporary_error(self, auth_state):
"""Complete the register confirmation details page with exports raising a temporary error"""
with override_settings(**get_cybersource_test_settings()), patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
with (
override_settings(**get_cybersource_test_settings()),
patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
),
):
assert_api_call(
self.client,
Expand Down Expand Up @@ -700,9 +708,12 @@ def register_compliance_export_reject_retry_blocked(self, auth_state):
def register_compliance_export_reject_retry_again(self, auth_state):
"""Complete the register compliance page with a retryable exception result"""
self.user = User.objects.get(email=self.email)
with override_settings(**get_cybersource_test_settings()), patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
with (
override_settings(**get_cybersource_test_settings()),
patch(
"authentication.pipeline.compliance.api.verify_user_with_exports",
side_effect=Exception("register_details_export_temporary_error"),
),
):
assert_api_call(
self.client,
Expand Down
Loading

0 comments on commit ce9f9d5

Please sign in to comment.