Skip to content

Commit

Permalink
Add run tests in pull request (#164)
Browse files Browse the repository at this point in the history
* Add run tests in pull request

* Add trigger dispatch tests based on pull_request event

* Update google response assertion

* Update tests assertion to be less strict
  • Loading branch information
kxtran authored May 29, 2024
1 parent bc72c3e commit 4365acf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Test

on:
pull_request:

schedule:
- cron: "0 13 * * *"
workflow_dispatch:
Expand Down Expand Up @@ -62,7 +64,7 @@ jobs:
run: poetry install --all-extras

- name: Run dispatch tests
if: ${{ github.event_name == 'workflow_dispatch' }}
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }}
run: |
echo "This is a dispatch event"
openai_model_input=${{ github.event.inputs.openai_model }}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_genai_chat(google_model):

text = response.text
assert isinstance(text, str)
assert "this is a test" in text.lower()
assert text, "No output from the model."


@pytest.mark.chat
Expand All @@ -39,4 +39,4 @@ def test_genai_chat_w_history(google_model):

text = response.text
assert isinstance(text, str)
assert "no" in text.lower()
assert text, "No output from the model."
5 changes: 3 additions & 2 deletions tests/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def test_chat_openai_messages(openai_model):
messages = [SystemMessage(content="You are a ping pong machine"), HumanMessage(content="Ping?")]
completion = llm.predict_messages(messages)

assert isinstance(completion.content, str)
assert "pong" in completion.content.lower()
content = completion.content
assert isinstance(content, str)
assert content, "No output from the model."


@pytest.mark.chat
Expand Down
3 changes: 2 additions & 1 deletion tests/test_magentic.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,6 @@ async def _generate_title_and_description(query: str, widget_data: str) -> Widge

assert isinstance(r, WidgetInfo)
assert isinstance(r.title, str)
assert "AAPL" in r.title
assert isinstance(r.description, str)
assert r.title, "No title generated."
assert r.description, "No description generated."
3 changes: 0 additions & 3 deletions tests/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def test_chat(openai_model):
content = completion.choices[0].message.content
assert isinstance(content, str)
assert content, "No output from the model."
assert "did not go to the market" in content


@pytest.mark.chat
Expand Down Expand Up @@ -68,7 +67,6 @@ async def test_chat_async(openai_model):
content = completion.choices[0].message.content
assert isinstance(content, str)
assert content, "No output from the model."
assert "this is a test" in content.lower()


@pytest.mark.chat
Expand Down Expand Up @@ -139,7 +137,6 @@ def test_chat_image(openai_vision_model):
content = response.choices[0].message.content
assert isinstance(content, str)
assert content, "No output from the model."
assert "ant" in content


def get_current_weather(location, unit="fahrenheit"):
Expand Down

0 comments on commit 4365acf

Please sign in to comment.