From 60095b43e5314a85c5687652355510f9523dfd1d Mon Sep 17 00:00:00 2001 From: Akshay Karle <1443108+akshaykarle@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:30:17 +0100 Subject: [PATCH] add TEST_USE_OPENAI env for running in github actions --- .github/workflows/test.yaml | 1 + tests/ask_repo_test.py | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index df4a54c..bb9cc7e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,5 +30,6 @@ jobs: - name: "Test" env: OPENAI_API_KEY: ${{ secrets.openai_api_key }} + TEST_USE_OPENAI: "true" run: 'poetry run pytest' shell: bash diff --git a/tests/ask_repo_test.py b/tests/ask_repo_test.py index d1e05ec..1346ade 100644 --- a/tests/ask_repo_test.py +++ b/tests/ask_repo_test.py @@ -4,16 +4,25 @@ from ask_repo import AskRepo -def test_invalid_repo_path(): - with pytest.raises(FileNotFoundError): - AskRepo("/non_existent_path") +class TestAskRepo: + @pytest.fixture + def model_name(self): + if os.getenv("TEST_USE_OPENAI"): + return "gpt-3.5-turbo" + else: + return "ollama/llama3.1:8b" -def test_repo_map(): - ask_repo = AskRepo(os.getcwd()) - assert "pyproject.toml" in ask_repo.get_repo_map() + def test_invalid_repo_path(self): + with pytest.raises(FileNotFoundError): + AskRepo("/non_existent_path") -def test_generates_valid_summary(): - ask_repo = AskRepo(os.getcwd(), "gpt-3.5-turbo") - assert "summary" in ask_repo.summarise() + def test_repo_map(self): + ask_repo = AskRepo(os.getcwd()) + assert "pyproject.toml" in ask_repo.get_repo_map() + + + def test_generates_valid_summary(self, model_name): + ask_repo = AskRepo(os.getcwd(), model_name) + assert "summary" in ask_repo.summarise()