Skip to content

Commit

Permalink
created test file for translator.py newly added
Browse files Browse the repository at this point in the history
  • Loading branch information
VeronicaPim authored Nov 15, 2024
1 parent 0cca4b4 commit 16d2f81
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test_translator.py
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

0 comments on commit 16d2f81

Please sign in to comment.