From 5ad961ba20cacf9e951c0a0af0fbd7695bd10dc8 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 22 Aug 2023 00:29:11 +0530 Subject: [PATCH] environment set test --- .github/workflows/test.yml | 3 --- cirun/tests/test_integration.py | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0dcf303..28e0342 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,5 @@ on: push -env: - CIRUN_API_KEY: ramdom-api-key - name: Test jobs: test: diff --git a/cirun/tests/test_integration.py b/cirun/tests/test_integration.py index d76cc49..2ec96be 100644 --- a/cirun/tests/test_integration.py +++ b/cirun/tests/test_integration.py @@ -1,22 +1,31 @@ +import os + +import pytest + from cirun import Cirun MSG_401 = "This API Key is expired or non-existent." -def test_access_control_add_repo_to_resource_401(): +@pytest.fixture +def set_api_key(): + os.environ['CIRUN_API_KEY'] = "random-key" + + +def test_access_control_add_repo_to_resource_401(set_api_key): cirun = Cirun() response = cirun.add_repo_to_resources("cirun", "cirun-py", resources=["cirun-runner-1"]) assert response.status_code == 401 assert response.json() == {"message": MSG_401} -def test_access_control_remove_repo_from_resource_401(): +def test_access_control_remove_repo_from_resource_401(set_api_key): cirun = Cirun() response = cirun.add_repo_to_resources("cirun", "cirun-py", resources=["cirun-runner-1"]) assert response.status_code == 401 assert response.json() == {"message": MSG_401} -def test_get_repo_resources(): +def test_get_repo_resources(set_api_key): cirun = Cirun() cirun.get_repo_resources(org="aktechlabs", repo="cirun-py")