def test_incorrect_guess(self): card = Card("What is the capital of Alaska?", "Juneau", "Geography") turn = Turn("Topeka", card) self.assertEqual(turn.card, card) self.assertEqual(turn.guess, "Topeka") self.assertFalse(turn.is_correct()) self.assertEqual(turn.feedback(), "Incorrect")
def test_correct_guess(self): card = Card("What is the capital of Alaska?", "Juneau", "Geography") turn = Turn("Juneau", card) self.assertEqual(turn.card, card) self.assertEqual(turn.guess, "Juneau") self.assertTrue(turn.is_correct()) self.assertEqual(turn.feedback(), "Correct!")
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!'
def setUp(self): card_one = Card("Heart", "5", 5) card_two = Card("Diamond", "Jack",11) card_three = Card("Spade", "7", 7) card_four = Card("Spade", "Ace", 14) cards = [card_one, card_two, card_three, card_four] self.deck = Deck(cards) self.player1 = Player("John", self.deck) card_five = Card("Heart", "8", 8) card_six = Card("Diamond", "Jack",11) card_seven = Card("Spade", "3", 3) card_eight = Card("Club", "Queen", 12) cards2 = [card_five, card_six, card_seven, card_eight] self.deck2 = Deck(cards2) self.player2 = Player("John", self.deck2) self.turn = Turn(self.player1, self.player2)
def test_it_has_attributes(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.guess == "Juneau" assert turn_1.card == card_1 assert turn_2.guess == "Monet" assert turn_2.card == card_2 assert turn_3.guess == "Mars" assert turn_3.card == card_3
def test_it_gives_feedback(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.feedback() == "Great job! Correct!" assert turn_2.feedback() == "Not quite. Try again!" assert turn_3.feedback() == "Great job! Correct!"
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
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 take_turn(self, guess): turn = Turn(guess, self.current_card()) self.turns.append(turn) if turn.is_correct(): self.number_correct += 1 return turn
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.'
def take_turn(self, guess): turn = Turn(guess, self.current_card()) self.deck.cards.pop(0) self.turns.append(turn) return turn
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_exists(self): category_1 = {"category": "Geography"} card_1 = Card("What is the capital of Alaska?", "Juneau", category_1) turn_1 = Turn("Juneau", card_1) assert isinstance(turn_1, Turn)
class TestTurn(unittest.TestCase): def setUp(self): card_one = Card("Heart", "5", 5) card_two = Card("Diamond", "Jack",11) card_three = Card("Spade", "7", 7) card_four = Card("Spade", "Ace", 14) cards = [card_one, card_two, card_three, card_four] self.deck = Deck(cards) self.player1 = Player("John", self.deck) card_five = Card("Heart", "8", 8) card_six = Card("Diamond", "Jack",11) card_seven = Card("Spade", "3", 3) card_eight = Card("Club", "Queen", 12) cards2 = [card_five, card_six, card_seven, card_eight] self.deck2 = Deck(cards2) self.player2 = Player("John", self.deck2) self.turn = Turn(self.player1, self.player2) def test_it_exists(self): assert type(self.turn) == Turn assert type(self.turn.player1) == Player assert type(self.turn.player2) == Player def test_turn_type_basic(self): assert self.turn.turn_type() == 'Basic' def test_turn_type_war(self): self.player2.deck.cards.insert(0, Card("Spade", "5", 5)) assert self.turn.turn_type() == 'War!' def test_turn_type_mad(self): self.player2.deck.cards.insert(0, Card("Spade", "5", 5)) self.player1.deck.cards.insert(1, Card("Diamond", "7", 7)) assert self.turn.turn_type() == 'MAD!' def test_pile_those_cards(self): self.turn.pile_those_cards(self.turn.player1.deck.cards, self.turn.player2.deck.cards) assert len(self.turn.spoils) == 2 assert len(self.turn.player1.deck.cards) == 3 assert len(self.turn.player2.deck.cards) == 3 def test_winner_basic(self): assert self.turn.turn_type() == 'Basic' self.turn.pile_those_cards(self.turn.player1.deck.cards, self.turn.player2.deck.cards) assert self.turn.winner() == self.player1 def test_winner_war(self): self.player2.deck.cards.insert(0, Card("Spade", "5", 5)) assert self.turn.turn_type() == 'War!' self.turn.pile_those_cards(self.turn.player1.deck.cards, self.turn.player2.deck.cards) assert self.turn.winner() == self.player2 def test_winner_mad(self): self.player2.deck.cards.insert(0, Card("Spade", "5", 5)) self.player1.deck.cards.insert(1, Card("Diamond", "7", 7)) assert self.turn.turn_type() == 'MAD!' assert self.turn.winner() == 'No Winner' def test_awards_spoils(self): self.turn.pile_those_cards(self.turn.player1.deck.cards, self.turn.player2.deck.cards) self.turn.award_spoils() assert len(self.turn.player1.deck.cards) == 5
def new_turn(self): self.turn_count += 1 return Turn(self.player1, self.player2)
def test_it_exists(self): card = Card("What is the capital of Alaska?", "Juneau", "Geography") turn = Turn("Juneau", card) self.assertIsInstance(turn, Turn)