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()