コード例 #1
0
ファイル: data_packet_test.py プロジェクト: bruingineer/sacn
def test_sourceName():
    # test string has 25 characters but is 64 bytes (1 too many) when UTF-8 encoded
    overlength_string = "𔑑覱֪I𤵎⠣Ķ'𫳪爓Û:𢏴㓑ò4𰬀鿹џ>𖬲膬ЩJ𞄇"
    packet = DataPacket(cid=tuple(range(0, 16)), sourceName="", universe=1)
    # test property setter
    with pytest.raises(TypeError):
        packet.sourceName = 0x33
    with pytest.raises(ValueError):
        packet.sourceName = overlength_string
    # test constructor
    with pytest.raises(ValueError):
        DataPacket(cid=tuple(range(0, 16)),
                   sourceName=overlength_string,
                   universe=1)
コード例 #2
0
ファイル: data_packet_test.py プロジェクト: bruingineer/sacn
def test_property_adjustment_and_deconstruction():
    # Converting DataPacket -> bytes -> DataPacket should produce the same result,
    # but with changed properties that are not the default
    built_packet = DataPacket(cid=(16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6,
                                   10, 7, 9, 8),
                              sourceName='Test Name',
                              universe=30)
    built_packet.cid = tuple(range(16))
    built_packet.sourceName = '2nd Test Name'
    built_packet.universe = 31425
    built_packet.dmxData = ((200, ) + tuple(range(255, 0, -1)) +
                            tuple(range(255)) + (0, ))
    built_packet.priority = 12
    built_packet.sequence = 45
    built_packet.option_StreamTerminated = True
    built_packet.option_PreviewData = True
    built_packet.option_ForceSync = True
    built_packet.syncAddr = 34003
    built_packet.dmxStartCode = 8
    read_packet = DataPacket.make_data_packet(built_packet.getBytes())
    assert read_packet.cid == tuple(range(16))
    assert read_packet.sourceName == '2nd Test Name'
    assert read_packet.universe == 31425
    assert read_packet.dmxData == ((200, ) + tuple(range(255, 0, -1)) +
                                   tuple(range(255)) + (0, ))
    assert read_packet.priority == 12
    assert read_packet.sequence == 45
    assert read_packet.option_StreamTerminated is True
    assert read_packet.option_PreviewData is True
    assert read_packet.option_ForceSync is True
    assert read_packet.syncAddr == 34003
    assert read_packet.dmxStartCode == 8