-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_functional.py
29 lines (20 loc) · 1.02 KB
/
test_functional.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from main import main
class TestMainFunction(unittest.TestCase):
def test_main_function(self):
n_results = 5
search_query = "large language models NLP benefits"
search_objective = "To find empirical evidence supporting the performance benefits of large language models in NLP tasks like text summarization, translation, and question-answering."
expected_keys = ["link", "snippet", "score", "ranking_score", "ai_content"]
result_dict = main(n_results, search_query, search_objective)
# Check if the result_dict has all the expected keys
self.assertTrue(all(key in result_dict for key in expected_keys))
# Additional checks can be added based on what you expect the function to return
ai_content = result_dict.get("ai_content")
self.assertIsNotNone(ai_content)
summary = None
if ai_content:
summary = ai_content.get("summary")
self.assertIsNotNone(summary)
if __name__ == "__main__":
unittest.main()