Exemple #1
0
def test_is_allstation1(chunk1):
    """test frame generated with unicast/allstation address for having one"""
    iframe = IFrame()
    iframe.parse_address(chunk1)
    assert iframe.is_allstation() is True
Exemple #2
0
def test_is_allstation3(chunk2):
    """"given a no-station address, testing is_allstation should yield False"""
    iframe = IFrame()
    iframe.parse_address(chunk2)
    assert iframe.is_allstation() is False
Exemple #3
0
def test_parse_address7():
    """unstripped input, 4 bytes, invalid closing flags"""
    iframe = IFrame()
    with pytest.raises(ValueError):
        iframe.parse_address(b'\x7e\x00\x00\x42')
Exemple #4
0
def test_parse_address9(chunk4):
    """parse I-frame control field with 1 byte address"""
    iframe = IFrame()
    iframe.parse_address(chunk4)
Exemple #5
0
def test_parse_address4():
    """stripped input: just two zero-bytes"""
    iframe = IFrame()
    with pytest.raises(ValueError):
        iframe.parse_address(bytes(2))
Exemple #6
0
def test_parse_address6():
    """unstripped input, 4 bytes, invalid opening flags"""
    iframe = IFrame()
    with pytest.raises(ValueError):
        iframe.parse_address(b'\x23\x00\x00\x7e')
Exemple #7
0
def test_parse_address3():
    """test for too short bytearray """
    iframe = IFrame()
    with pytest.raises(TypeError):
        iframe.parse_address(bytearray(1))
Exemple #8
0
def test_parse_address2():
    """test for rejecting float input"""
    iframe = IFrame()
    with pytest.raises(TypeError):
        iframe.parse_address(2.3)
Exemple #9
0
def test_is_nostation3(chunk2):
    """parsing a no-station address should return True in is_nostation()"""
    iframe = IFrame()
    iframe.parse_address(chunk2)
    assert iframe.is_nostation() is True
Exemple #10
0
def test_is_nostation2(chunk1):
    """parsing a all-station address should return False on is_nostation()"""
    iframe = IFrame()
    iframe.parse_address(chunk1)
    assert iframe.is_nostation() is False
Exemple #11
0
def test_parse_address1():
    """test for rejecting strings"""
    iframe = IFrame()
    with pytest.raises(TypeError):
        iframe.parse_address('test')