uranusjr commented on a change in pull request #18757:
URL: https://github.com/apache/airflow/pull/18757#discussion_r723114533
##########
File path: tests/api_connexion/endpoints/test_user_endpoint.py
##########
@@ -472,6 +472,45 @@ def test_change_with_update_maek(self, autoclean_username,
autoclean_user_payloa
assert data["first_name"] == "Changed"
assert data["last_name"] == "User"
+ @pytest.mark.parametrize(
+ "payload, error_message",
+ [
+ ({"username": "another_user"}, "The username `another_user`
already exists"),
+ ({"email": "[email protected]"}, "The email
`[email protected]` already exists"),
+ ],
+ ids=["username", "email"],
+ )
+ @pytest.mark.usefixtures("user_different")
+ @pytest.mark.usefixtures("autoclean_admin_user")
+ def test_patch_already_exists(
+ self,
+ payload,
+ error_message,
+ autoclean_user_payload,
+ autoclean_username,
+ ):
+ autoclean_user_payload.update(payload)
+ response = self.client.patch(
+ f"/api/v1/users/{autoclean_username}",
+ json=autoclean_user_payload,
+ environ_overrides={"REMOTE_USER": "test"},
+ )
+ assert response.status_code == 409, response.json
+
+ assert response.json["detail"] == error_message
+
+ @pytest.mark.usefixtures('autoclean_admin_user')
+ def test_username_can_be_updated(self, autoclean_user_payload,
autoclean_username):
+ testusername = 'testusername'
+ autoclean_user_payload.update({"username": testusername})
+ response = self.client.patch(
+ f"/api/v1/users/{autoclean_username}",
+ json=autoclean_user_payload,
+ environ_overrides={"REMOTE_USER": "test"},
+ )
+ assert response.json['username'] == testusername
+ _delete_user(username=testusername)
Review comment:
This would cause the db to not be cleaned up correctly if the assertion
above fails. The cleanup needs to be placed in a fixture instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]