Пример #1
0
class EventTest(BaseUnitTest):
    def setUp(self):
        self.emu = Emulator()

    def test_create_new_street_event(self):
        message = {
            'message_type': 'street_start_message',
            'street': 'preflop',
            'round_state': 1
        }
        event = self.emu.create_event(message)
        self.eq('event_new_street', event['type'])
        self.eq('preflop', event['street'])
        self.eq(1, event['round_state'])

    def test_create_ask_player_event(self):
        message = {
            'message_type': 'ask_message',
            'hole_card': 1,
            'valid_actions': 2,
            'round_state': TwoPlayerSample.round_state,
            'action_histories': [4, 5]
        }
        event = self.emu.create_event(message)
        self.eq('event_ask_player', event['type'])
        self.eq(2, event['valid_actions'])
        self.eq(TwoPlayerSample.round_state, event['round_state'])
        self.eq('pwtwlmfciymjdoljkhagxa', event['uuid'])

    def test_create_round_finish_event(self):
        message = {
            'message_type':
            'round_result_message',
            'round_count':
            2,
            'round_state':
            TwoPlayerSample.round_state,
            'hand_info': [],
            'winners': [{
                'stack': 105,
                'state': 'participating',
                'name': 'p2',
                'uuid': 'pwtwlmfciymjdoljkhagxa'
            }]
        }
        event = self.emu.create_event(message)
        self.eq('event_round_finish', event['type'])
        self.eq(TwoPlayerSample.round_state, event['round_state'])
        self.eq('pwtwlmfciymjdoljkhagxa', event['winners'][0]['uuid'])
        self.eq(105, event['winners'][0]['stack'])

    def test_create_game_finish_event(self):
        message = {
            'message_type': 'game_result_message',
            'game_information': {
                'player_num':
                2,
                'rule': {
                    'max_round': 10,
                    'initial_stack': 100,
                    'small_blind_amount': 5
                },
                'seats': [{
                    'stack': 0,
                    'state': 'folded',
                    'name': 'p1',
                    'uuid': 'tojrbxmkuzrarnniosuhct'
                }, {
                    'stack': 200,
                    'state': 'participating',
                    'name': 'p2',
                    'uuid': 'pwtwlmfciymjdoljkhagxa'
                }]
            }
        }
        event = self.emu.create_event(message)
        self.eq('event_game_finish', event['type'])
        self.eq('tojrbxmkuzrarnniosuhct', event['players'][0]['uuid'])
        self.eq(0, event['players'][0]['stack'])
        self.eq('pwtwlmfciymjdoljkhagxa', event['players'][1]['uuid'])
        self.eq(200, event['players'][1]['stack'])
Пример #2
0
class EventTest(BaseUnitTest):

    def setUp(self):
        self.emu = Emulator()

    def test_create_new_street_event(self):
        message = {
                "message_type": "street_start_message",
                "street": "preflop",
                "round_state": 1
                }
        event = self.emu.create_event(message)
        self.eq("event_new_street", event["type"])
        self.eq("preflop", event["street"])
        self.eq(1, event["round_state"])

    def test_create_ask_player_event(self):
        message = { 
                "message_type": "ask_message",
                "hole_card": 1,
                "valid_actions": 2,
                "round_state": TwoPlayerSample.round_state,
                "action_histories": [4,5]
                }
        event = self.emu.create_event(message)
        self.eq("event_ask_player", event["type"])
        self.eq(2, event["valid_actions"])
        self.eq(TwoPlayerSample.round_state, event["round_state"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["uuid"])

    def test_create_round_finish_event(self):
        message = {
                "message_type": "round_result_message",
                "round_count": 2,
                "round_state": TwoPlayerSample.round_state,
                "hand_info": [],
                "winners": [{'stack': 105, 'state': 'participating', 'name': 'p2', 'uuid': 'pwtwlmfciymjdoljkhagxa'}]
                }
        event = self.emu.create_event(message)
        self.eq("event_round_finish", event["type"])
        self.eq(TwoPlayerSample.round_state, event["round_state"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["winners"][0]["uuid"])
        self.eq(105, event["winners"][0]["stack"])

    def test_create_game_finish_event(self):
        message = {
                'message_type': 'game_result_message',
                'game_information': {
                    'player_num': 2,
                    'rule': {'max_round': 10, 'initial_stack': 100, 'small_blind_amount': 5},
                    "seats": [
                        {'stack': 0, 'state': 'folded', 'name': 'p1', 'uuid': 'tojrbxmkuzrarnniosuhct'},
                        {'stack': 200, 'state': 'participating', 'name': 'p2', 'uuid': 'pwtwlmfciymjdoljkhagxa'}
                    ]
                }
                }
        event = self.emu.create_event(message)
        self.eq("event_game_finish", event["type"])
        self.eq("tojrbxmkuzrarnniosuhct", event["players"][0]["uuid"])
        self.eq(0, event["players"][0]["stack"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["players"][1]["uuid"])
        self.eq(200, event["players"][1]["stack"])
Пример #3
0
class EventTest(BaseUnitTest):
    def setUp(self):
        self.emu = Emulator()

    def test_create_new_street_event(self):
        message = {
            "message_type": "street_start_message",
            "street": "preflop",
            "round_state": 1
        }
        event = self.emu.create_event(message)
        self.eq("event_new_street", event["type"])
        self.eq("preflop", event["street"])
        self.eq(1, event["round_state"])

    def test_create_ask_player_event(self):
        message = {
            "message_type": "ask_message",
            "hole_card": 1,
            "valid_actions": 2,
            "round_state": TwoPlayerSample.round_state,
            "action_histories": [4, 5]
        }
        event = self.emu.create_event(message)
        self.eq("event_ask_player", event["type"])
        self.eq(2, event["valid_actions"])
        self.eq(TwoPlayerSample.round_state, event["round_state"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["uuid"])

    def test_create_round_finish_event(self):
        message = {
            "message_type":
            "round_result_message",
            "round_count":
            2,
            "round_state":
            TwoPlayerSample.round_state,
            "hand_info": [],
            "winners": [{
                'stack': 105,
                'state': 'participating',
                'name': 'p2',
                'uuid': 'pwtwlmfciymjdoljkhagxa'
            }]
        }
        event = self.emu.create_event(message)
        self.eq("event_round_finish", event["type"])
        self.eq(TwoPlayerSample.round_state, event["round_state"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["winners"][0]["uuid"])
        self.eq(105, event["winners"][0]["stack"])

    def test_create_game_finish_event(self):
        message = {
            'message_type': 'game_result_message',
            'game_information': {
                'player_num':
                2,
                'rule': {
                    'max_round': 10,
                    'initial_stack': 100,
                    'small_blind_amount': 5
                },
                "seats": [{
                    'stack': 0,
                    'state': 'folded',
                    'name': 'p1',
                    'uuid': 'tojrbxmkuzrarnniosuhct'
                }, {
                    'stack': 200,
                    'state': 'participating',
                    'name': 'p2',
                    'uuid': 'pwtwlmfciymjdoljkhagxa'
                }]
            }
        }
        event = self.emu.create_event(message)
        self.eq("event_game_finish", event["type"])
        self.eq("tojrbxmkuzrarnniosuhct", event["players"][0]["uuid"])
        self.eq(0, event["players"][0]["stack"])
        self.eq("pwtwlmfciymjdoljkhagxa", event["players"][1]["uuid"])
        self.eq(200, event["players"][1]["stack"])