Пример #1
0
def generated_packet() -> PositionPacket:
    p = PositionPacket()

    p.source = "XX1XX"
    p.destination = "APRS"
    p.path = "TCPIP"

    p.symbol_table = "/"
    p.symbol_id = "k"

    p.latitude = 51.5
    p.longitude = -100

    p.comment = "Test comment"

    return p
Пример #2
0
def test_parse_uncompressed_position():
    lat, lng, amb, st, sid = PositionPacket._parse_uncompressed_position("5100.00N/11400.00Wk")

    assert lat == 51
    assert lng == -114
    assert amb == 0
    assert st == "/"
    assert sid == "k"
Пример #3
0
def test_parse_compressed_position_with_altitude():
    (lat, lng, alt, course, speed, radio_range, fix, source,
     origin) = PositionPacket._parse_compressed_position("/5L!!<*e7OS]S")

    assert lat == 49.5
    assert lng == -72.750004
    assert alt == 10004.52

    assert fix == CompressionFix.OLD
    assert source == CompressionSource.OTHER
    assert origin == CompressionOrigin.COMPRESSED
Пример #4
0
def test_parse_compressed_position_without_altitude():

    (lat, lng, alt, course, speed, radio_range, fix, source,
     origin) = PositionPacket._parse_compressed_position("/5L!!<*e7> sT")

    assert lat == 49.5
    assert lng == -72.750004
    assert alt is None

    assert fix is None
    assert source is None
    assert origin is None
Пример #5
0
def test_parse_compressed_position_with_radio_range():

    (lat, lng, alt, course, speed, radio_range, fix, source,
     origin) = PositionPacket._parse_compressed_position("/5L!!<*e7>{?!")

    assert lat == 49.5
    assert lng == -72.750004
    assert radio_range == 20.13

    assert fix == CompressionFix.CURRENT
    assert source == CompressionSource.GLL
    assert origin == CompressionOrigin.TNC_BTEXT
Пример #6
0
def test_parse_invalid_uncompressed_position():
    with pytest.raises(ParseError):
        # Missing symbol ID
        PositionPacket._parse_uncompressed_position("5100.00N/11400.00W")
Пример #7
0
def test_generate_compressed(latitude, longitude, timestamp, timestamp_type, messaging,
                             expected_output):
    p = PositionPacket()

    p.source = "XX1XX"
    p.destination = "APRS"
    p.path = "TCPIP"

    p.symbol_table = "/"
    p.symbol_id = "k"

    p.latitude = latitude
    p.longitude = longitude

    p.timestamp = timestamp
    p.timestamp_type = timestamp_type

    p.messaging = messaging
    p.comment = "Test comment"
    p.compressed = True

    output = p.generate()

    assert output == expected_output
Пример #8
0
def test_invalid_compressed_type():
    p = PositionPacket()

    with pytest.raises(TypeError):
        p.compressed = None
Пример #9
0
def test_invalid_messaging_type():
    p = PositionPacket()

    with pytest.raises(TypeError):
        p.messaging = None
Пример #10
0
def test_parse_data_with_altitude():
    phg, rng, dfs, course, speed, altitude, comment = PositionPacket._parse_data(
        "/A=002000Test status"
    )

    assert altitude == 2000
Пример #11
0
def test_parse_data_with_dfs():
    phg, rng, dfs, course, speed, altitude, comment = PositionPacket._parse_data(
        "DFS2360"
    )

    assert dfs == "2360"
Пример #12
0
def test_parse_data_with_rng():
    phg, rng, dfs, course, speed, altitude, comment = PositionPacket._parse_data(
        "RNG0050"
    )

    assert rng == "0050"
Пример #13
0
def test_parse_data_with_phg():
    phg, rng, dfs, course, speed, altitude, comment = PositionPacket._parse_data(
        "PHG5132"
    )

    assert phg == "5132"
Пример #14
0
def test_init():
    packet = PositionPacket()
    point = Point(51, -114, 1000)

    packet.point = point
    packet.power = 50
    packet.height = 50
    packet.gain = 3
    packet.directivity = 90
    packet.radio_range = 10
    packet.strength = 9
    packet.bearing = 180
    packet.number = 12.5
    packet.df_range = 20
    packet.quality = 1

    assert packet.point == point
    assert packet.power == 50
    assert packet.height == 50
    assert packet.gain == 3
    assert packet.directivity == 90
    assert packet.radio_range == 10
    assert packet.strength == 9
    assert packet.bearing == 180
    assert packet.number == 12.5
    assert packet.df_range == 20
    assert packet.quality == 1
Пример #15
0
def test_empty():
    packet = PositionPacket()

    assert str(packet) == "<PositionPacket>"