Пример #1
0
 def test_buy_supplement(self):
     """
     Tests the buy_supplement method mocking user's input.
     """
     deck_game = Game()
     deck_game.player_1._money = 6
     deck_game.central['supplement'].push(Card('Archer', 3, 3, 6))
     with patch('__builtin__.raw_input', return_value='S'):
         deck_game.player_1_buy()
         self.assertEqual(deck_game.player_1.money, 0)
         self.assertEqual(deck_game.central['supplement'].size(), 0)
Пример #2
0
 def test_buy_card(self):
     """
     Tests the buy_card method mocking user's input.
     """
     deck_game = Game()
     deck_game.player_1._money = 3
     deck_game.central['active'].push(Card('Archer', 2, 2, 3))
     with patch('__builtin__.raw_input', return_value='0'):
         deck_game.player_1_buy()
         self.assertEqual(deck_game.player_1.money, 0)
         self.assertEqual(deck_game.central['active'].size(), 0)
Пример #3
0
 def test_buy_card_invalid_index(self):
     """
     Tests the card method mocking user's input and giving an invalid index
     for the card to buy.
     """
     deck_game = Game()
     deck_game.player_1._money = 3
     deck_game.central['active'].push(Card('Archer', 2, 2, 3))
     with patch('__builtin__.raw_input', side_effect=['1', 'E']):
         deck_game.player_1_buy()
         self.assertEqual(deck_game.player_1.money, 3)
         self.assertEqual(deck_game.central['active'].size(), 1)