Skip to content

Commit

Permalink
add TEST_USE_OPENAI env for running in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaykarle committed Sep 10, 2024
1 parent f895131 commit 60095b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 18 additions & 9 deletions tests/ask_repo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 60095b4

Please sign in to comment.