def test_it_can_tell_accuracy(self): category_1 = {"category": "Geography"} card_1 = Card("What is the capital of Alaska?", "Juneau", category_1) category_2 = {"category": "Art"} card_2 = Card("Who painted Starry Night?", "Vincent Van Gogh", category_2) category_3 = {"category": "STEM"} card_3 = Card( "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", category_3) turn_1 = Turn("Juneau", card_1) turn_2 = Turn("Monet", card_2) turn_3 = Turn("Mars", card_3) assert turn_1.correct() == True assert turn_2.correct() == False assert turn_3.correct() == True
def test_turn(self): card = Card("What is the capital of Alaska?", "Juneau", 'Geography') turn = Turn('Juneau', card) assert turn.card == card assert turn.guess == 'Juneau' assert turn.correct() == True assert turn.feedback() == 'Correct!'
class Test(unittest.TestCase): def setUp(self): self.card = Card("Geography", "What is it?", "I don't know!") self.turn = Turn("I know!", self.card) self.turn2 = Turn("I don't know!", self.card) def test_it_has_attributes(self): self.assertEqual(self.turn.guess, "I know!") self.assertEqual(self.turn2.guess, "I don't know!") self.assertEqual(self.turn.card.category, 'Geography') self.assertEqual(self.turn.card.question, "What is it?") self.assertEqual(self.turn.card.answer, "I don't know!") def test_correct(self): self.assertFalse(self.turn.correct()) self.assertTrue(self.turn2.correct()) def test_feedback(self): self.assertEqual(self.turn.feedback(), 'Incorrect.') self.assertEqual(self.turn2.feedback(), 'Correct!')
def test_incorrect_guess(self): card = Card("What is the capital of Alaska?", "Juneau", 'Geography') turn = Turn('Juno', card) assert turn.correct() == False assert turn.feedback() == 'Incorrect.'