import unittest from programmatic_solvers import try_programmatic_answer class ProgrammaticSolverTests(unittest.TestCase): def test_solves_reversed_instruction_without_task_id(self): question = '.rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI' self.assertEqual(try_programmatic_answer(question), "Right") def test_solves_noncommutative_elements_from_markdown_table(self): question = """ Given this table defining * on the set S = {a, b, c} |*|a|b|c| |---|---|---|---| |a|a|b|c| |b|c|b|a| |c|c|a|c| Provide the list of elements involved in making * not commutative. """ self.assertEqual(try_programmatic_answer(question), "a, b") def test_filters_botanical_vegetables_and_alphabetizes(self): question = """ I'm making a grocery list. Please alphabetize the list of vegetables: apples, broccoli, celery, fresh basil, lettuce, strawberries, sweet potatoes, tomatoes. """ self.assertEqual( try_programmatic_answer(question), "broccoli, celery, fresh basil, lettuce, sweet potatoes", ) def test_unknown_question_returns_none(self): self.assertIsNone(try_programmatic_answer("Who wrote Hamlet?")) if __name__ == "__main__": unittest.main()