Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 10, 2024
1 parent 7901341 commit 2f17ade
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@
"filename": "users/serializers.py",
"hashed_secret": "ab90d9d736f9e0909b62d0922e0482e4b827449f",
"is_verified": false,
"line_number": 234
"line_number": 241
}
]
},
"generated_at": "2024-10-03T19:08:49Z"
"generated_at": "2024-10-10T16:34:17Z"
}
15 changes: 6 additions & 9 deletions users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
USERNAME_ALREADY_EXISTS_MSG = (
"A user already exists with this username. Please try a different one."
)
EMAIL_CONFLICT_MSG = (
"This email is already associated with an existing account")
RETIRED_EMAIL_MSG = (
"This email is associated to a retired account."
)
EMAIL_CONFLICT_MSG = "This email is already associated with an existing account"
RETIRED_EMAIL_MSG = "This email is associated to a retired account."

OPENEDX_VALIDATION_MSGS_MAP = {
"It looks like this username is already taken": USERNAME_ALREADY_EXISTS_MSG,
Expand Down Expand Up @@ -245,15 +242,15 @@ def validate(self, data):
{"username": "This field is required."}
)
if not data.get("email"):
raise serializers.ValidationError(
{"email": "This field is required."}
)
raise serializers.ValidationError({"email": "This field is required."})

username = data.get("username")
email = data.get("email")
if username:
try:
openedx_validation_msg = validate_username_email_with_edx(username, email)
openedx_validation_msg = validate_username_email_with_edx(
username, email
)
openedx_validation_msg = OPENEDX_VALIDATION_MSGS_MAP.get(
openedx_validation_msg, openedx_validation_msg
)
Expand Down
4 changes: 3 additions & 1 deletion users/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ def test_username_validation_connection_exception(
UserSerializer should raise a RequestsConnectionError or HTTPError if the connection to OpenEdx
fails. The serializer should raise a validation error.
"""
mocker.patch("openedx.api.validate_username_email_with_edx", side_effect=exception_raised)
mocker.patch(
"openedx.api.validate_username_email_with_edx", side_effect=exception_raised
)

serializer = UserSerializer(
data={
Expand Down

0 comments on commit 2f17ade

Please sign in to comment.