Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2024
1 parent 6a073c4 commit 4d5a9d0
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions tests/integration_tests/users/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from tests.integration_tests.constants import ADMIN_USERNAME

meUri = "/api/v1/me/"
AVATAR_URL = "/internal/avatar.png"


class TestCurrentUserApi(SupersetTestCase):
Expand Down Expand Up @@ -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")
Expand All @@ -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

0 comments on commit 4d5a9d0

Please sign in to comment.