Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2024
1 parent fc5ced4 commit 6a073c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 6 additions & 1 deletion superset/utils/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def get_slack_client() -> WebClient:

def get_user_avatar(email: str, client: WebClient = None) -> str:
client = client or get_slack_client()

print("HEREHREHRHEHRHR")
print("HEREHREHRHEHRHR")
print("HEREHREHRHEHRHR")
print("HEREHREHRHEHRHR")
print("HEREHREHRHEHRHR")
print("HEREHREHRHEHRHR")
try:
response = client.users_lookupByEmail(email=email)
except Exception as ex:
Expand Down
19 changes: 12 additions & 7 deletions tests/integration_tests/users/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ def test_avatar_valid_user_no_avatar(self):
response = self.client.get("/api/v1/user/1/avatar.png", follow_redirects=False)
assert response.status_code == 204

@patch("superset.utils.slack.get_user_avatar", return_value=AVATAR_URL)
@with_config({"SLACK_API_TOKEN": "dummy", "SLACK_ENABLE_AVATARS": True})
def test_avatar_with_valid_user(self, mock):
def test_avatar_with_valid_user(self):
self.login(ADMIN_USERNAME)

response = self.client.get("/api/v1/user/1/avatar.png", follow_redirects=False)
# mock.assert_called_once_with("[email protected]")
assert response.status_code == 204
# assert response.headers["Location"] == self.AVATAR_URL
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

0 comments on commit 6a073c4

Please sign in to comment.