def test_init_central_deck(self): """ Tests whether the central deck size is the expected one after initialising the deck. """ deck_game = Game() deck_game.init_central_deck() self.assertEqual(deck_game.central['deck'].size(), 36)
def test_player_turn(self): """ Tests the player_turn method mocking user's input. It gives valid as well as invalid input, covering all possible branches. """ deck_game = Game() deck_game.init_central_deck() deck_game.player_1.init_deck() deck_game.central['active'].push(Card('Archer', 1, 3, 3), 5) deck_game.player_1.hand.push(Card('Archer', 1, 0, 0)) deck_game.player_1.hand.push(Card('Archer', 0, 1, 0)) deck_game.player_1.hand.push(Card('Archer', 1, 1, 1)) deck_game.player_1.hand.push(Card('Archer', 2, 2, 3), 2) deck_size = deck_game.player_1.deck.size() with patch('__builtin__.raw_input', side_effect=['0', '0', 'A', 'P', 'B', '0', 'B', '0', 'A']): deck_game.player_1_turn() self.assertEquals(deck_game.player_1.hand.size(), 5) self.assertEquals(deck_game.player_1.deck.size(), deck_size - 5)