Example #1
0
    def test_tournament_end_no_ack(self):
        # Test that RPP will return False if no ack received for tournament_end
        rpp = RemotePlayerProxy('name', 1.0, self.dummy_socket)
        rpp._RemotePlayerProxy__socket = self.mock_socket
        self.mock_socket.recv.return_value = b'["testing"]'
        expected_client_request = f'["end", [true]]'

        with patch.object(rpp, '_RemotePlayerProxy__send_message') as mock:
            ack = rpp.tournament_has_ended(True)
            mock.assert_called_with(expected_client_request)
            self.assertEqual(ack, False)
Example #2
0
    def test_tournament_end_success(self):
        # Test that RPP can successfully send a tournament end message and recieve ack
        rpp = RemotePlayerProxy('name', 1.0, self.dummy_socket)
        rpp._RemotePlayerProxy__socket = self.mock_socket
        self.mock_socket.recv.return_value = b'"void"'
        expected_client_request = f'["end", [false]]'

        with patch.object(rpp, '_RemotePlayerProxy__send_message') as mock:
            ack = rpp.tournament_has_ended(False)
            mock.assert_called_with(expected_client_request)
            self.assertEqual(ack, True)