Skip to content

Commit

Permalink
fixing hook
Browse files Browse the repository at this point in the history
  • Loading branch information
annagav committed Oct 10, 2024
1 parent 7901341 commit 3dc53d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 3 additions & 8 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,9 +242,7 @@ 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")
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 3dc53d8

Please sign in to comment.