示例#1
0
def test_websocketservice__parse_message__return_expected_type():
    # arrange
    ws_service = WebSocketService()

    # act
    result = ws_service._parse_message('some message')

    # assert
    assert isinstance(result, WebSocketParsedCommandEntity)
示例#2
0
def test_websocketservice__register_command__adds_command():
    # arrange
    ws_service = WebSocketService()
    commands_len = len(ws_service.commands)

    async def some_awaitable():
        pass

    # act
    ws_service.register_command('some-new-command', some_awaitable, [])

    # assert
    assert len(ws_service.commands) == commands_len + 1
    assert 'some-new-command' in ws_service.commands
示例#3
0
async def test_websocketservice__process_message__return_expected(
        message, expected):
    # arrange
    ws_service = WebSocketService()

    # act
    result = await ws_service.process_message(message)

    # assert
    assert result == expected
示例#4
0
async def test_websocketservice__invalid_command__return_expected_type():
    # arrange
    ws_service = WebSocketService()
    command = WebSocketParsedCommandEntity('any', ['args'])

    # act
    result = await ws_service._invalid_command_result(command)

    # assert
    assert isinstance(result, WebSocketCommandResultEntity)
示例#5
0
async def test_websocketservice__ping__return_expected():
    # arrange
    ws_service = WebSocketService()

    # act
    result = await ws_service._ping('any')

    # assert
    assert isinstance(result, WebSocketCommandResultEntity)
    assert result.result == 'pong'
示例#6
0
def test_websocketservice__commands__exists_with_expected_type():
    # arrange
    ws_service = WebSocketService()

    # assert
    assert isinstance(ws_service.commands, MappingProxyType)