Skip to content

Commit

Permalink
fix: add missing error message to PUT /user (#925)
Browse files Browse the repository at this point in the history
Error message for missing all fields in update user profile is added.
Closes #597
Signed off by: @devkapilbansal
  • Loading branch information
devkapilbansal authored Dec 12, 2020
1 parent ba599ab commit 20f4dfc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/api/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def get(cls):
@users_ns.expect(auth_header_parser, update_user_request_body_model)
@users_ns.response(HTTPStatus.OK, "%s" % messages.USER_SUCCESSFULLY_UPDATED)
@users_ns.response(
HTTPStatus.BAD_REQUEST, "%s" % messages.NAME_INPUT_BY_USER_IS_INVALID
HTTPStatus.BAD_REQUEST,
f"{messages.NAME_INPUT_BY_USER_IS_INVALID}\n{messages.NO_DATA_FOR_UPDATING_PROFILE_WAS_SENT}",
)
def put(cls):
"""
Expand Down
2 changes: 1 addition & 1 deletion app/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

# Update
NO_DATA_FOR_UPDATING_PROFILE_WAS_SENT = {
"message": "No data for updating" "profile was sent."
"message": "No data for updating profile was sent."
}

# Relation constraints
Expand Down
20 changes: 5 additions & 15 deletions tests/admin/test_api_remove_admin_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def test_remove_self_admin_status_with_other_admins_api_resource_auth_admin(self
expected_response = messages.USER_ADMIN_STATUS_WAS_REVOKED
actual_response = self.client.post(
"/admin/remove",
json={
"user_id": self.admin_user_1.id,
},
json={"user_id": self.admin_user_1.id},
follow_redirects=True,
headers=auth_header,
)
Expand All @@ -72,9 +70,7 @@ def test_remove_self_admin_status_when_only_admin_api_resource_auth_admin(self):
expected_response = messages.USER_ADMIN_STATUS_WAS_REVOKED
actual_response = self.client.post(
"/admin/remove",
json={
"user_id": self.admin_user_2.id,
},
json={"user_id": self.admin_user_2.id},
follow_redirects=True,
headers=auth_header,
)
Expand All @@ -87,9 +83,7 @@ def test_remove_self_admin_status_when_only_admin_api_resource_auth_admin(self):
expected_response = messages.USER_ADMIN_STATUS_WAS_REVOKED
actual_response = self.client.post(
"/admin/remove",
json={
"user_id": 1,
},
json={"user_id": 1},
follow_redirects=True,
headers=auth_header,
)
Expand All @@ -102,9 +96,7 @@ def test_remove_self_admin_status_when_only_admin_api_resource_auth_admin(self):
expected_response = messages.USER_CANNOT_REVOKE_ADMIN_STATUS
actual_response = self.client.post(
"/admin/remove",
json={
"user_id": self.admin_user_1.id,
},
json={"user_id": self.admin_user_1.id},
follow_redirects=True,
headers=auth_header,
)
Expand All @@ -117,9 +109,7 @@ def test_remove_admin_status_api_resource_auth_admin(self):
expected_response = messages.USER_ADMIN_STATUS_WAS_REVOKED
actual_response = self.client.post(
"/admin/remove",
json={
"user_id": self.admin_user_2.id,
},
json={"user_id": self.admin_user_2.id},
follow_redirects=True,
headers=auth_header,
)
Expand Down

0 comments on commit 20f4dfc

Please sign in to comment.