Skip to content

Commit

Permalink
fix: solve error for running tests without Zulip API Key (#102)
Browse files Browse the repository at this point in the history
Closes #82
  • Loading branch information
devkapilbansal authored and decon-harsh committed Mar 7, 2021
1 parent f15b6a6 commit 6e82848
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coverage==5.4
- name: Creating Zulip API key
run: echo -e "${{ secrets.ZULIP_API_KEY }}" >> download
- name: Exporting Secret Key
run: echo -e "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
Expand Down
9 changes: 8 additions & 1 deletion osp/utils/zulip_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# By default the API key file you download is named as 'download' by Zulip. You can place
# this file one directory previous to the cuurent directory your file is in
client = Client(config_file="download")


def get_client():
return Client(config_file="download")

def get_self_zulip_id():
result = client.get_profile()
Expand All @@ -18,6 +21,7 @@ def get_zulip_user(zulip_id: int) -> dict:
{"avatar_url": "...","bot_type": null,... "profile_data":...}
"""

client = get_client()
result = client.get_user_by_id(zulip_id)
print(result)
return result["user"]
Expand All @@ -34,6 +38,7 @@ def get_total_messages_count(zulip_id: int) -> int:
10
"""

client = get_client()
request = {
"anchor": "newest",
"num_before": 5000,
Expand All @@ -55,6 +60,7 @@ def get_newest_message(zulip_id: int) -> dict:
{"avatar_url": ...,"bot_type": null, ..., "profile_data":...}
"""

client = get_client()
request = {
"anchor": "newest",
"num_before": 1,
Expand All @@ -76,6 +82,7 @@ def get_stream_messages_count(stream: str, zulip_id: int) -> int:
10
"""

client = get_client()
request = {
"anchor": "newest",
"num_before": 1,
Expand Down

0 comments on commit 6e82848

Please sign in to comment.