File size: 1,393 Bytes
2da6a11
352f525
2da6a11
352f525
2da6a11
 
352f525
2da6a11
 
 
 
352f525
2da6a11
 
 
 
352f525
2da6a11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352f525
2da6a11
 
352f525
2da6a11
 
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
30
31
32
33
34
35
36
37
38
39
40
import unittest

import requests

from main_v2 import main


class TestQuestions(unittest.TestCase):
    def setUp(self):
        self.api_url = "https://agents-course-unit4-scoring.hf.space"
        self.questions_url = f"{self.api_url}/questions"

        # Get questions from the API
        response = requests.get(self.questions_url, timeout=15)
        response.raise_for_status()
        self.questions = response.json()

        # Expected answers for each question
        self.expected_answers = {
            "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.": "3",
            # Add more expected answers as you verify them
        }

    def test_questions(self):
        """Test each question and verify the succinct answer matches the expected value."""
        for question_data in self.questions:
            question = question_data["question"]
            if question in self.expected_answers:
                expected_answer = self.expected_answers[question]
                actual_answer = main(question)
                self.assertEqual(
                    actual_answer,
                    expected_answer,
                    f"Question: {question}\nExpected: {expected_answer}\nGot: {actual_answer}",
                )


if __name__ == "__main__":
    unittest.main()