Пример #1
0
 def test_player_from_symbol(self):
    game = Game()
    player = Player(game)
    Moves(game).perform({
      "player": "X",
      "position": [1,1]
    })
    self.assertEqual(player.player_from_symbol("X"),
                     player.get_players()[0])
Пример #2
0
 def setUp(self):
     self.p = Player()
Пример #3
0
 def test_init_with_name(self):
     expected = "foo"
     p = Player(expected)
     self.assertEqual(p.name, expected, "name isn't foo")
Пример #4
0
 def test_update_symbol(self):
   game = Game({ "players": [ { "symbol": "X", "name": "X"},
               {"symbol": "Y", "name": "Y"}] })
   player = Player(game)
Пример #5
0
 def test_switching_active_player(self):
   game = Game()
   player = Player(game)
   self.assertEqual(player.get_active_symbol(),"X")
   player.switch_active()
   self.assertEqual(player.get_active_symbol(),"O")
Пример #6
0
 def test_get_opponent_symbol(self):
   game = Game()
   player = Player(game)
   symbol = player.get_opponent_symbol("O")
   self.assertEqual(symbol,"X")
Пример #7
0
 def test_starting_player_is_valid(self):
   game = Game({ "players": [ { "symbol": "B", "name": "B"}, \
               {"symbol": "A", "name": "A"}] })
   player = Player(game)
   self.assertIn(player.get_active_symbol(),player.valid_symbols())
Пример #8
0
 def test_nondefault_valid_symbols(self):
   game = Game({ "players": [ { "symbol": "B", "name": "B"}, \
               {"symbol": "A", "name": "A"}] })
   player = Player(game)
   self.assertEqual(set(player.valid_symbols()),{"A","B"})
Пример #9
0
 def test_default_valid_symbols(self):
   game = Game()
   player = Player(game)
   self.assertEqual(set(player.valid_symbols()),{"X","O"})
Пример #10
0
 def test_valid_symbols_is_a_set(self):
   symbols = Player(Game()).valid_symbols()
   self.assertIsInstance(symbols,list)