Skip to content

Commit 7f3f77f

Browse files
fix writer tests
1 parent 761732b commit 7f3f77f

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.909211, 39.700356, 8201.8632]}, "properties": {"time": "20181111102013", "altitude": 8201.8632, "ascent_rate": 0.0, "ground_speed": 0.0, "callsign": "W3EAX-8"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.881058, 39.700099, 8645.652]}, "properties": {"time": "20181111102124", "altitude": 8645.652, "ascent_rate": 6.251, "ground_speed": 34.01, "callsign": "W3EAX-8"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.425253, 39.641857, 13130.784]}, "properties": {"time": "20190203143928", "altitude": 13130.784000000001, "ascent_rate": 0.001, "ground_speed": 0.005, "callsign": "W3EAX-13"}}, {"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-77.909211, 39.700356, 8201.8632], [-77.881058, 39.700099, 8645.652], [-77.425253, 39.641857, 13130.784]]}, "properties": {"time": "20190203143928", "altitude": 13130.784000000001, "ascent_rate": 0.001, "ground_speed": 0.005, "seconds_to_ground": -1.0, "callsign": "W3EAX-13"}}]}
1+
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.909211, 39.700356, 8201.8632]}, "properties": {"time": "20181111102013", "altitude": 8201.8632, "ascent_rate": 0.0, "ground_speed": 0.0, "callsign": "W3EAX-8"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.881058, 39.700099, 8645.652]}, "properties": {"time": "20181111102124", "altitude": 8645.652, "ascent_rate": 6.251, "ground_speed": 34.01, "callsign": "W3EAX-8"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.425253, 39.641857, 13130.784]}, "properties": {"time": "20190203143928", "altitude": 13130.784000000001, "ascent_rate": 0.001, "ground_speed": 0.005, "callsign": "W3EAX-8"}}, {"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-77.909211, 39.700356, 8201.8632], [-77.881058, 39.700099, 8645.652], [-77.425253, 39.641857, 13130.784]]}, "properties": {"time": "20190203143928", "altitude": 13130.784000000001, "ascent_rate": 0.001, "ground_speed": 0.005, "seconds_to_ground": -1.0, "callsign": "W3EAX-8"}}]}

tests/reference/test_output.kml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<kml:kml xmlns:kml="http://www.opengis.net/kml/2.2"><kml:Document id="1"><kml:name>root document</kml:name><kml:description>root document, containing geometries</kml:description><kml:visibility>1</kml:visibility><kml:Placemark id="1 0 0"><kml:name>20181111102013 W3EAX-13</kml:name><kml:description>altitude=8201.8632 ascent_rate=0.0 ground_speed=0.0</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.909211,39.700356,8201.863200</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0 1"><kml:name>20181111102124 W3EAX-13</kml:name><kml:description>altitude=8645.652 ascent_rate=6.251 ground_speed=34.01</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.881058,39.700099,8645.652000</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0 2"><kml:name>20190203143928 W3EAX-13</kml:name><kml:description>altitude=13130.784000000001 ascent_rate=0.001 ground_speed=0.005</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.425253,39.641857,13130.784000</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0"><kml:name>W3EAX-13</kml:name><kml:description>altitude=13130.784000000001 ascent_rate=0.001 ground_speed=0.005 seconds_to_ground=-1.0</kml:description><kml:visibility>1</kml:visibility><kml:LineString><kml:coordinates>-77.909211,39.700356,8201.863200 -77.881058,39.700099,8645.652000 -77.425253,39.641857,13130.784000</kml:coordinates></kml:LineString></kml:Placemark></kml:Document></kml:kml>
1+
<kml:kml xmlns:kml="http://www.opengis.net/kml/2.2"><kml:Document id="1"><kml:name>root document</kml:name><kml:description>root document, containing geometries</kml:description><kml:visibility>1</kml:visibility><kml:Placemark id="1 0 0"><kml:name>20181111102013 W3EAX-8</kml:name><kml:description>altitude=8201.8632 ascent_rate=0.0 ground_speed=0.0</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.909211,39.700356,8201.863200</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0 1"><kml:name>20181111102124 W3EAX-8</kml:name><kml:description>altitude=8645.652 ascent_rate=6.251 ground_speed=34.01</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.881058,39.700099,8645.652000</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0 2"><kml:name>20190203143928 W3EAX-8</kml:name><kml:description>altitude=13130.784000000001 ascent_rate=0.001 ground_speed=0.005</kml:description><kml:visibility>1</kml:visibility><kml:Point><kml:coordinates>-77.425253,39.641857,13130.784000</kml:coordinates></kml:Point></kml:Placemark><kml:Placemark id="1 0"><kml:name>W3EAX-8</kml:name><kml:description>altitude=13130.784000000001 ascent_rate=0.001 ground_speed=0.005 seconds_to_ground=-1.0</kml:description><kml:visibility>1</kml:visibility><kml:LineString><kml:coordinates>-77.909211,39.700356,8201.863200 -77.881058,39.700099,8645.652000 -77.425253,39.641857,13130.784000</kml:coordinates></kml:LineString></kml:Placemark></kml:Document></kml:kml>

tests/reference/test_output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
2018-11-11 10:20:13 EST: W3EAX-8>APRS,WIDE1-1,WIDE2-1,qAR,K3DO-11:!/:Gh=:j)#O /A=026909|!Q| /W3EAX,262,0,18'C,http://www.umd.edu
22
2018-11-11 10:21:24 EST: W3EAX-8>APRS,N3TJJ-12,WIDE1*,WIDE2-1,qAR,N3FYI-2:!/:GiD:jcwO /A=028365|!R| /W3EAX,267,0,18'C,http://www.umd.edu
3-
2019-02-03 14:39:28 EST: W3EAX-13>APRS,KC3FIT-1,WIDE1*,WIDE2-1,qAR,KC3AWP-10:!/:JL2:u4wO /A=043080|!j| /W3EAX,326,0,20'C,nearspace.umd.edu
3+
2019-02-03 14:39:28 EST: W3EAX-8>APRS,KC3FIT-1,WIDE1*,WIDE2-1,qAR,KC3AWP-10:!/:JL2:u4wO /A=043080|!j| /W3EAX,326,0,20'C,nearspace.umd.edu

tests/test_writer.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
from tempfile import TemporaryDirectory
44

5+
import pytest
56
import pytz
67

78
from packetraven.packets import APRSPacket
@@ -11,58 +12,61 @@
1112

1213
REFERENCE_DIRECTORY = repository_root() / 'tests' / 'reference'
1314

14-
PACKET_TRACK = APRSTrack(
15-
'W3EAX-13',
16-
[
17-
APRSPacket.from_frame(
18-
"W3EAX-8>APRS,WIDE1-1,WIDE2-1,qAR,K3DO-11:!/:Gh=:j)#O /A=026909|!Q| /W3EAX,262,0,18'C,http://www.umd.edu",
19-
packet_time=pytz.timezone('America/New_York').localize(
20-
datetime(2018, 11, 11, 10, 20, 13)
15+
16+
@pytest.fixture
17+
def packet_track():
18+
return APRSTrack(
19+
'W3EAX-8',
20+
[
21+
APRSPacket.from_frame(
22+
"W3EAX-8>APRS,WIDE1-1,WIDE2-1,qAR,K3DO-11:!/:Gh=:j)#O /A=026909|!Q| /W3EAX,262,0,18'C,http://www.umd.edu",
23+
packet_time=pytz.timezone('America/New_York').localize(
24+
datetime(2018, 11, 11, 10, 20, 13)
25+
),
2126
),
22-
),
23-
APRSPacket.from_frame(
24-
"W3EAX-8>APRS,N3TJJ-12,WIDE1*,WIDE2-1,qAR,N3FYI-2:!/:GiD:jcwO /A=028365|!R| /W3EAX,267,0,18'C,"
25-
'http://www.umd.edu',
26-
packet_time=pytz.timezone('America/New_York').localize(
27-
datetime(2018, 11, 11, 10, 21, 24)
27+
APRSPacket.from_frame(
28+
"W3EAX-8>APRS,N3TJJ-12,WIDE1*,WIDE2-1,qAR,N3FYI-2:!/:GiD:jcwO /A=028365|!R| /W3EAX,267,0,18'C,"
29+
'http://www.umd.edu',
30+
packet_time=pytz.timezone('America/New_York').localize(
31+
datetime(2018, 11, 11, 10, 21, 24)
32+
),
2833
),
29-
),
30-
APRSPacket.from_frame(
31-
"W3EAX-13>APRS,KC3FIT-1,WIDE1*,WIDE2-1,qAR,KC3AWP-10:!/:JL2:u4wO /A=043080|!j| /W3EAX,326,0,20'C,"
32-
'nearspace.umd.edu',
33-
packet_time=pytz.timezone('America/New_York').localize(
34-
datetime(2019, 2, 3, 14, 39, 28)
34+
APRSPacket.from_frame(
35+
"W3EAX-8>APRS,KC3FIT-1,WIDE1*,WIDE2-1,qAR,KC3AWP-10:!/:JL2:u4wO /A=043080|!j| /W3EAX,326,0,20'C,"
36+
'nearspace.umd.edu',
37+
packet_time=pytz.timezone('America/New_York').localize(
38+
datetime(2019, 2, 3, 14, 39, 28)
39+
),
3540
),
36-
),
37-
],
38-
)
41+
],
42+
)
3943

4044

41-
def test_write_kml():
45+
def test_write_kml(packet_track):
4246
filename = 'test_output.kml'
4347
reference_filename = REFERENCE_DIRECTORY / filename
4448
with TemporaryDirectory() as temporary_directory:
4549
output_filename = Path(temporary_directory) / filename
46-
write_packet_tracks([PACKET_TRACK], output_filename)
50+
write_packet_tracks([packet_track], output_filename)
4751
with open(output_filename) as output_file, open(reference_filename) as reference_file:
4852
assert output_file.read() == reference_file.read()
4953

5054

51-
def test_write_geojson():
55+
def test_write_geojson(packet_track):
5256
filename = 'test_output.geojson'
5357
reference_filename = REFERENCE_DIRECTORY / filename
5458
with TemporaryDirectory() as temporary_directory:
5559
output_filename = Path(temporary_directory) / filename
56-
write_packet_tracks([PACKET_TRACK], output_filename)
60+
write_packet_tracks([packet_track], output_filename)
5761
with open(output_filename) as output_file, open(reference_filename) as reference_file:
5862
assert output_file.read() == reference_file.read()
5963

6064

61-
def test_write_txt():
65+
def test_write_txt(packet_track):
6266
filename = 'test_output.txt'
6367
reference_filename = REFERENCE_DIRECTORY / filename
6468
with TemporaryDirectory() as temporary_directory:
6569
output_filename = Path(temporary_directory) / filename
66-
write_packet_tracks([PACKET_TRACK], output_filename)
70+
write_packet_tracks([packet_track], output_filename)
6771
with open(output_filename) as output_file, open(reference_filename) as reference_file:
6872
assert output_file.read() == reference_file.read()

0 commit comments

Comments
 (0)