From 54a8a5c65fbe3580734a755889addc02e3770d1e Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Sat, 16 Mar 2024 12:00:10 -0400 Subject: [PATCH] feat(tests): enhance `test_querybot` with stream target and input validations - 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. --- tests/bot/test_querybot.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/bot/test_querybot.py b/tests/bot/test_querybot.py index 13d3cc0ce..7d0228d46 100644 --- a/tests/bot/test_querybot.py +++ b/tests/bot/test_querybot.py @@ -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?")