コード例 #1
0
ファイル: test_connection.py プロジェクト: findepi/pymx
def create_connections_manager(multiplexer_password=None):
    welcome = WelcomeMessage()
    welcome.id = 547
    welcome.type = 115
    if multiplexer_password is not None:
        welcome.multiplexer_password = multiplexer_password
    welcome_message = MultiplexerMessage()
    welcome_message.from_ = 547
    welcome_message.message = welcome.SerializeToString()
    welcome_message.type = MessageTypes.CONNECTION_WELCOME
    return ConnectionsManager(welcome_message=welcome_message, multiplexer_password=multiplexer_password)
コード例 #2
0
ファイル: test_message.py プロジェクト: findepi/pymx
def test_from():
    # Check that ``from_`` and ``from`` can be used interchangeably.
    msg = MultiplexerMessage()
    msg.from_ = 10
    assert getattr(msg, 'from') == 10
    setattr(msg, 'from', 20)
    assert msg.from_ == 20

    # Check that the value assigned via ``from_`` is properly serialized.
    msg = MultiplexerMessage()
    msg.from_ = 15
    assert msg.SerializePartialToString() == '\x10\x0f'

    # Check hat the deserialized ``from`` can be read via ``from_``.
    assert parse_message(MultiplexerMessage, '\x10\x0f', partial=True).from_ == 15
コード例 #3
0
ファイル: test_message.py プロジェクト: findepi/pymx
def test_serialize():
    # The order of serialized fields is not guaranteed, so we can check
    # serialization using one field only.
    msg = MultiplexerMessage()
    msg.type = 3 # This should be the only required field.
    assert msg.SerializeToString() == ' \x03'