Skip to content

Commit

Permalink
Add an integration test with streamlit app
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaC215 committed Dec 10, 2024
1 parent 1fb349d commit c758e75
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/integration/test_docker_e2e.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from streamlit.testing.v1 import AppTest

from client import AgentClient

Expand All @@ -13,3 +14,24 @@ def test_service_with_fake_model():
response = client.invoke("Tell me a joke?", model="fake")
assert response.type == "ai"
assert response.content == "This is a test response from the fake model."


@pytest.mark.docker
def test_service_with_app():
"""Test the service using the app.
This test requires the service container to be running with USE_FAKE_MODEL=true
"""
at = AppTest.from_file("../../src/streamlit_app.py").run()
assert at.chat_message[0].avatar == "assistant"
welcome = at.chat_message[0].markdown[0].value
assert welcome.startswith("Hello! I'm an AI-powered research assistant")
assert not at.exception

at.sidebar.selectbox[1].set_value("chatbot")
at.chat_input[0].set_value("What is the weather in Tokyo?").run()
assert at.chat_message[0].avatar == "user"
assert at.chat_message[0].markdown[0].value == "What is the weather in Tokyo?"
assert at.chat_message[1].avatar == "assistant"
assert at.chat_message[1].markdown[0].value == "This is a test response from the fake model."
assert not at.exception

0 comments on commit c758e75

Please sign in to comment.