Skip to content

Commit

Permalink
feat(tests): enhance test_querybot with stream target and input val…
Browse files Browse the repository at this point in the history
…idations

- Add minimum size constraints to `dummy_text` and `mock_response` in `test_querybot` to ensure more realistic test data.
- Introduce `stream_target` parameter to `QueryBot` instantiation within `test_querybot`, allowing tests to specify output stream (either "panel" or "stdout").
- Rename `test_querybot_init` to `test_querybot` to better reflect the test's purpose, which now includes sending a query to the bot.
- Execute a sample query against the `QueryBot` instance to verify its operational status post-initialization.

This enhancement aims to improve the robustness and coverage of `QueryBot` testing by ensuring the presence of meaningful test data and by testing a broader spectrum of the bot's functionality.
  • Loading branch information
ericmjl committed Mar 16, 2024
1 parent 603ad73 commit 54a8a5c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/bot/test_querybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
collection_name=st.text(
alphabet="abcdefghijklmnopqrstuvwxyz0123456789", min_size=4, max_size=63
),
dummy_text=st.text(),
mock_response=st.text(),
human_message=st.text(),
dummy_text=st.text(min_size=400),
mock_response=st.text(min_size=4),
stream_target=st.one_of(st.just("panel"), st.just("stdout")),
)
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture], deadline=None)
def test_querybot_init(
tmp_path, system_prompt, collection_name, dummy_text, mock_response, human_message
def test_querybot(
tmp_path, system_prompt, collection_name, dummy_text, mock_response, stream_target
):
"""Test initialization of QueryBot."""
tempfile = tmp_path / "test.txt"
tempfile.write_text(dummy_text)

QueryBot(
bot = QueryBot(
system_prompt=system_prompt,
collection_name=collection_name,
document_paths=tempfile,
mock_response=mock_response,
stream_target=stream_target,
)

bot("How are you doing?")

0 comments on commit 54a8a5c

Please sign in to comment.