Пример #1
0
class TestBot(unittest.TestCase):

    def setUp(self):
        self.game_state = {'_stateID': 1234, 'G': {}, 'ctx': {
            'actionPlayers': ['1'],
            'phase': 'phase0'
        }}
        self.resulting_move = {'payload': 'action0'}
        # mock socket
        io.SocketIO = mock.Mock(spec=io.SocketIO)
        # instantiate SUT
        self.sut = Bot()
        self.sut.think = mock.MagicMock(name='think')
        self.sut.gameover = mock.MagicMock(name='gameover')

    def test_make_move_shall_return_move_action(self):
        self.assertEqual(self.sut.make_move('type', 'foo', 'bar'),
                         {'type': 'MAKE_MOVE',
                          'payload': {
                              'type': 'type',
                              'args': ['foo', 'bar'],
                              'playerID': self.sut.player_id
                          }})

    def test_game_event_shall_return_event_action(self):
        self.assertEqual(self.sut.game_event('foobar'),
                         {'type': 'GAME_EVENT',
                          'payload': {
                              'type': 'foobar',
                              'args': [],
                              'playerID': self.sut.player_id}
                         })
Пример #2
0
 def __init__(self):
     Bot.__init__(self,
                  server='localhost',
                  port=8000,
                  options={
                      'game_name': 'default',
                      'num_players': 2,
                      'player_id': '1'
                  })
Пример #3
0
 def setUp(self):
     self.game_state = {'_stateID': 1234, 'G': {}, 'ctx': {
         'actionPlayers': ['1'],
         'phase': 'phase0'
     }}
     self.resulting_move = {'payload': 'action0'}
     # mock socket
     io.SocketIO = mock.Mock(spec=io.SocketIO)
     # instantiate SUT
     self.sut = Bot()
     self.sut.think = mock.MagicMock(name='think')
     self.sut.gameover = mock.MagicMock(name='gameover')
Пример #4
0
 def __init__(self):
     Bot.__init__(self, server='localhost', port=8000, game_name='default', num_players=2, player_id='1')