Skip to content

Commit 257d317

Browse files
m-tthwvanous
authored andcommitted
Cherry picked and linted new test file
1 parent 73e4dda commit 257d317

1 file changed

Lines changed: 32 additions & 19 deletions

File tree

tests/test_own_pack_unpack.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import binascii
1+
#!/bin/env python3
2+
"""
3+
Test packing and parsing our own data.
4+
"""
25
import pypsn
3-
from pathlib import Path
4-
# Test packing and parsing our own data
56

67

7-
psn_info = pypsn.psn_info_packet(
8-
info=pypsn.psn_info(
8+
psn_info = pypsn.PsnInfoPacket(
9+
info=pypsn.PsnInfo(
910
timestamp=1312,
1011
version_high=2,
1112
version_low=0,
@@ -15,42 +16,42 @@
1516
name="system_name_001",
1617
trackers=(
1718
[
18-
pypsn.psn_tracker_info(
19+
pypsn.PsnTrackerInfo(
1920
tracker_id=i,
2021
tracker_name="tracker_" + str(i),
2122
)
2223
for i in range(0, 7)
2324
]
2425
),
2526
)
26-
psn_data = pypsn.psn_data_packet(
27+
psn_data = pypsn.PsnDataPacket(
2728
info=psn_info.info,
2829
trackers=(
2930
[
30-
pypsn.psn_tracker(
31-
id=tracker.tracker_id,
31+
pypsn.PsnTracker(
32+
tracker_id=tracker.tracker_id,
3233
info=psn_info.info,
33-
pos=pypsn.psn_vector3(
34+
pos=pypsn.PsnVector3(
3435
x=0.0,
3536
y=0.0,
3637
z=0.0,
3738
),
38-
speed=pypsn.psn_vector3(
39+
speed=pypsn.PsnVector3(
3940
x=0.0,
4041
y=0.0,
4142
z=0.0,
4243
),
43-
ori=pypsn.psn_vector3(
44+
ori=pypsn.PsnVector3(
4445
x=0.0,
4546
y=0.0,
4647
z=0.0,
4748
),
48-
accel=pypsn.psn_vector3(
49+
accel=pypsn.PsnVector3(
4950
x=0.0,
5051
y=0.0,
5152
z=0.0,
5253
),
53-
trgtpos=pypsn.psn_vector3(
54+
trgtpos=pypsn.PsnVector3(
5455
x=0.0,
5556
y=0.0,
5657
z=0.0,
@@ -65,19 +66,31 @@
6566

6667

6768
def get_test_data():
69+
"""
70+
Get test data.
71+
72+
Returns:
73+
psn data packet: as bytes
74+
"""
6875
return pypsn.prepare_psn_data_packet_bytes(psn_data)
6976

7077

7178
def get_test_info():
79+
"""
80+
Get test info.
81+
82+
Returns:
83+
psn data packet: as bytes
84+
"""
7285
return pypsn.prepare_psn_info_packet_bytes(psn_info)
7386

7487

7588
def test_data_data(pypsn_module):
7689
"""Test position"""
7790
hexdata = get_test_data()
7891
data = pypsn_module.parse_psn_packet(hexdata)
79-
test_vector = pypsn_module.psn_vector3(0.0, 0.0, 0.0)
80-
if isinstance(data, pypsn_module.psn_data_packet):
92+
test_vector = pypsn_module.PsnVector3(0.0, 0.0, 0.0)
93+
if isinstance(data, pypsn_module.PsnDataPacket):
8194
assert test_vector == data.trackers[0].pos
8295

8396

@@ -86,7 +99,7 @@ def test_data_info(pypsn_module):
8699

87100
hexdata = get_test_data()
88101
data = pypsn_module.parse_psn_packet(hexdata)
89-
if isinstance(data, pypsn_module.psn_data_packet):
102+
if isinstance(data, pypsn_module.PsnDataPacket):
90103
assert 56 == data.info.frame_id
91104
assert 1 == data.info.packet_count
92105
assert 1312 == data.info.timestamp
@@ -99,7 +112,7 @@ def test_info_info(pypsn_module):
99112

100113
hexdata = get_test_data()
101114
data = pypsn_module.parse_psn_packet(hexdata)
102-
if isinstance(data, pypsn_module.psn_info_packet):
115+
if isinstance(data, pypsn_module.PsnInfoPacket):
103116
assert b"system_name_001" == data.name
104117
assert 56 == data.info.frame_id
105118
assert 1 == data.info.packet_count
@@ -113,5 +126,5 @@ def test_info_data(pypsn_module):
113126

114127
hexdata = get_test_info()
115128
data = pypsn_module.parse_psn_packet(hexdata)
116-
if isinstance(data, pypsn_module.psn_info_packet):
129+
if isinstance(data, pypsn_module.PsnInfoPacket):
117130
assert data.trackers[0].tracker_name == b"tracker_0"

0 commit comments

Comments
 (0)