forked from CMU-313/cmu-313-f24-nodebb-f24-NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created test file for translator.py newly added
- Loading branch information
1 parent
0cca4b4
commit 16d2f81
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from unittest import mock | ||
from unittest.mock import patch | ||
from translator import query_llm_robust | ||
|
||
#mocking the LLM API response for normal response | ||
@patch('translator.llm_queries.query_llm_robust') | ||
def test_llm_normal_response(mock_query_llm_robust): | ||
#define the expected LLM response | ||
expected_response = (False, "Here is your first example.") | ||
mock_query_llm_robust.return_value = expected_response | ||
|
||
#call the function under test | ||
result = query_llm_robust("Hier ist dein erstes Beispiel.") | ||
|
||
#validate the result | ||
assert result == expected_response | ||
|
||
#mocking the LLM API response for gibberish response | ||
@patch('translator.llm_queries.query_llm_robust') | ||
def test_llm_gibberish_response(mock_query_llm_robust): | ||
#define the expected LLM response for gibberish input | ||
expected_response = (False, "Error: Invalid translation response.") | ||
mock_query_llm_robust.return_value = expected_response | ||
|
||
#call the function under test | ||
result = query_llm_robust("sdflkjqwepoijqwe") #gibberish input | ||
|
||
#validate the result | ||
assert result == expected_response |