-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for radio ip, udp/ipv4 compressed header and elements
- Loading branch information
Showing
10 changed files
with
84 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
okdmr/tests/dmrlib/etsi/layer3/elements/test_ip_address_identifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from bitarray import bitarray | ||
|
||
from okdmr.dmrlib.etsi.layer3.elements.ip_address_identifier import IPAddressIdentifier | ||
|
||
|
||
def test_said_daid(): | ||
said = IPAddressIdentifier.from_bits(bits=bitarray("0001")) | ||
assert said == IPAddressIdentifier.USBEthernetInterfaceNetwork | ||
assert said.as_bits() == bitarray("0001") | ||
|
||
assert IPAddressIdentifier(3) == IPAddressIdentifier.Reserved | ||
assert IPAddressIdentifier(13) == IPAddressIdentifier.ManufacturerSpecific |
11 changes: 11 additions & 0 deletions
11
okdmr/tests/dmrlib/etsi/layer3/elements/test_udp_port_identifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from bitarray import bitarray | ||
|
||
from okdmr.dmrlib.etsi.layer3.elements.udp_port_identifier import UDPPortIdentifier | ||
|
||
|
||
def test_spid_dpid(): | ||
assert UDPPortIdentifier(1) == UDPPortIdentifier.UTF16BE_TextMessage | ||
assert UDPPortIdentifier.from_bits(bitarray("0000010")).as_bits() == bitarray( | ||
"0000010" | ||
) | ||
assert UDPPortIdentifier(4) == UDPPortIdentifier.Reserved |
19 changes: 19 additions & 0 deletions
19
okdmr/tests/dmrlib/etsi/layer3/pdu/test_udp_ipv4_compressed_header.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from bitarray import bitarray | ||
|
||
from okdmr.dmrlib.etsi.layer3.pdu.udp_ipv4_compressed_header import ( | ||
UDPIPv4CompressedHeader, | ||
) | ||
|
||
|
||
def test_extended_headers(): | ||
both: UDPIPv4CompressedHeader = UDPIPv4CompressedHeader.from_bits( | ||
bitarray("0" * 72) | ||
) | ||
assert both.extended_header_2 is not None | ||
assert both.extended_header_1 is not None | ||
|
||
single: UDPIPv4CompressedHeader = UDPIPv4CompressedHeader.from_bits( | ||
bitarray("0" * 31 + "1" + "0" * 40) | ||
) | ||
assert single.extended_header_1 is not None | ||
assert single.extended_header_2 is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
from typing import List, Tuple | ||
|
||
import pytest | ||
|
||
from okdmr.dmrlib.hytera.pdu.radio_ip import RadioIP | ||
|
||
|
||
@pytest.mark.skip | ||
def test_radio_ip(): | ||
rips: List[Tuple] = [ | ||
# rcp | ||
("0800000a", "10.0.0.8", 8, "little"), | ||
# rrs, lp, tp, dtp | ||
("0a000001", "10.0.0.1", 1, "big"), | ||
("0a000050", "10.0.0.80", 80, "big"), | ||
("0a2110dd", "10", 10, "big"), | ||
# rcp | ||
("0800000a", "10.0.0.8", 8, "little"), | ||
("0a2110dd", "10.33.16.221", 2167005, "big"), | ||
] | ||
for rip_bytes, ip_str, radio_id, endian in rips: | ||
rip = RadioIP.from_bytes(data=bytes.fromhex(rip_bytes), endian=endian) | ||
assert rip.subnet == 10 | ||
assert rip.radio_id == radio_id | ||
assert rip.as_ip() == ip_str | ||
assert len(repr(rip)) | ||
|
||
rip = RadioIP.from_ip(ip="10.33.16.221", endian="big") | ||
assert rip.as_ip() == "10.33.16.221" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters