diff --git a/tests/integration_tests/users/api_tests.py b/tests/integration_tests/users/api_tests.py index 55b702e0d97ab..44711d96f27a9 100644 --- a/tests/integration_tests/users/api_tests.py +++ b/tests/integration_tests/users/api_tests.py @@ -26,6 +26,7 @@ from tests.integration_tests.constants import ADMIN_USERNAME meUri = "/api/v1/me/" +AVATAR_URL = "/internal/avatar.png" class TestCurrentUserApi(SupersetTestCase): @@ -67,8 +68,6 @@ def test_get_me_anonymous(self, mock_g): class TestUserApi(SupersetTestCase): - AVATAR_URL = "/internal/avatar.png" - def test_avatar_with_invalid_user(self): self.login(ADMIN_USERNAME) response = self.client.get("/api/v1/user/NOT_A_USER/avatar.png") @@ -83,16 +82,10 @@ def test_avatar_valid_user_no_avatar(self): assert response.status_code == 204 @with_config({"SLACK_API_TOKEN": "dummy", "SLACK_ENABLE_AVATARS": True}) - def test_avatar_with_valid_user(self): + @patch("superset.views.users.api.get_user_avatar", return_value=AVATAR_URL) + def test_avatar_with_valid_user(self, mock): self.login(ADMIN_USERNAME) - with patch( - "superset.views.users.api.get_user_avatar", return_value=self.AVATAR_URL - ) as mock: - # with patch("superset.utils.slack.get_user_avatar", return_value=self.AVATAR_URL) as mock: - response = self.client.get( - "/api/v1/user/1/avatar.png", follow_redirects=False - ) - # slack.get_user_avatar("admin@fab.org") - mock.assert_called_once_with("admin@fab.org") - assert response.status_code == 301 - assert response.headers["Location"] == self.AVATAR_URL + response = self.client.get("/api/v1/user/1/avatar.png", follow_redirects=False) + mock.assert_called_once_with("admin@fab.org") + assert response.status_code == 301 + assert response.headers["Location"] == AVATAR_URL