diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 556374c..db7e43d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/osp/utils/zulip_api.py b/osp/utils/zulip_api.py index 2bf39cb..af88b29 100644 --- a/osp/utils/zulip_api.py +++ b/osp/utils/zulip_api.py @@ -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() @@ -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"] @@ -34,6 +38,7 @@ def get_total_messages_count(zulip_id: int) -> int: 10 """ + client = get_client() request = { "anchor": "newest", "num_before": 5000, @@ -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, @@ -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,