-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a073c4
commit 4d5a9d0
Showing
1 changed file
with
7 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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("[email protected]") | ||
mock.assert_called_once_with("[email protected]") | ||
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("[email protected]") | ||
assert response.status_code == 301 | ||
assert response.headers["Location"] == AVATAR_URL |