23
23
24
24
import pytest
25
25
26
- from aiscot .ais_functions import read_known_craft_fd
27
- from aiscot .constants import DEFAULT_MID_DB_FILE , DEFAULT_SHIP_DB_FILE
28
- from aiscot .functions import ais_to_cot , cot_to_xml
26
+ import aiscot
29
27
30
28
31
29
@pytest .fixture
@@ -115,11 +113,11 @@ def sample_known_craft():
115
113
366892000,TACO_01,a-f-S-T-A-C-O,
116
114
"""
117
115
csv_fd = io .StringIO (sample_csv )
118
- return read_known_craft_fd (csv_fd )
116
+ return aiscot . ais_functions . read_known_craft_fd (csv_fd )
119
117
120
118
121
119
def test_ais_to_cot (sample_data_pyAISm ):
122
- cot = ais_to_cot (sample_data_pyAISm )
120
+ cot = aiscot . ais_to_cot (sample_data_pyAISm )
123
121
assert isinstance (cot , ET .Element )
124
122
assert cot .tag == "event"
125
123
assert cot .attrib ["version" ] == "2.0"
@@ -154,7 +152,7 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft):
154
152
or [{}]
155
153
)[0 ]
156
154
157
- cot = ais_to_cot (sample_data_pyAISm , known_craft = known_craft )
155
+ cot = aiscot . ais_to_cot (sample_data_pyAISm , known_craft = known_craft )
158
156
159
157
assert isinstance (cot , ET .Element )
160
158
assert cot .tag == "event"
@@ -181,9 +179,9 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft):
181
179
182
180
183
181
def test_ais_to_cot_none ():
184
- """Test that `ais_to_cot()` only renders valid input data."""
182
+ """Test that `aiscot. ais_to_cot()` only renders valid input data."""
185
183
assert (
186
- ais_to_cot (
184
+ aiscot . ais_to_cot (
187
185
{
188
186
"mmsi" : 366892000 ,
189
187
"lon" : 0 ,
@@ -193,7 +191,7 @@ def test_ais_to_cot_none():
193
191
is None
194
192
)
195
193
assert (
196
- ais_to_cot (
194
+ aiscot . ais_to_cot (
197
195
{
198
196
"mmsi" : 366892000 ,
199
197
"lon" : - 122.51208 ,
@@ -203,7 +201,7 @@ def test_ais_to_cot_none():
203
201
is None
204
202
)
205
203
assert (
206
- ais_to_cot (
204
+ aiscot . ais_to_cot (
207
205
{
208
206
"mmsi" : "" ,
209
207
"lon" : - 122.51208 ,
@@ -212,23 +210,23 @@ def test_ais_to_cot_none():
212
210
)
213
211
is None
214
212
)
215
- assert ais_to_cot ({}) is None
213
+ assert aiscot . ais_to_cot ({}) is None
216
214
217
215
218
216
def test_ais_to_cot_dont_ignore_aton (sample_aton ):
219
217
"""Test ignoring Aids to Naviation (ATON)."""
220
- assert ais_to_cot (sample_aton , {"IGNORE_ATON" : False }) is not None
218
+ assert aiscot . ais_to_cot (sample_aton , {"IGNORE_ATON" : False }) is not None
221
219
222
220
223
221
def test_ais_to_cot_ignore_aton (sample_aton ):
224
222
"""Test ignoring Aids to Naviation (ATON)."""
225
- assert ais_to_cot (sample_aton , {"IGNORE_ATON" : True }) is None
223
+ assert aiscot . ais_to_cot (sample_aton , {"IGNORE_ATON" : True }) is None
226
224
227
225
228
226
def test_ais_to_cot_shipname (sample_data_pyAISm ):
229
227
"""Test converting AIS to CoT with a known shipname."""
230
228
sample_data_pyAISm ["mmsi" ] = "303990000"
231
- cot = ais_to_cot (sample_data_pyAISm )
229
+ cot = aiscot . ais_to_cot (sample_data_pyAISm )
232
230
233
231
detail = cot .findall ("detail" )
234
232
assert detail [0 ].tag == "detail"
@@ -240,7 +238,7 @@ def test_ais_to_cot_shipname(sample_data_pyAISm):
240
238
def test_ais_to_cot_sar (sample_data_pyAISm ):
241
239
"""Test converting AIS to CoT for a SAR vessel."""
242
240
sample_data_pyAISm ["mmsi" ] = "303862000"
243
- cot = ais_to_cot (sample_data_pyAISm )
241
+ cot = aiscot . ais_to_cot (sample_data_pyAISm )
244
242
245
243
assert cot .tag == "event"
246
244
assert cot .attrib ["type" ] == "a-f-S-X-L"
@@ -249,14 +247,14 @@ def test_ais_to_cot_sar(sample_data_pyAISm):
249
247
def test_ais_to_cot_crs (sample_data_pyAISm ):
250
248
"""Test converting AIS to CoT for a CRS vessel."""
251
249
sample_data_pyAISm ["mmsi" ] = "3669123"
252
- cot = ais_to_cot (sample_data_pyAISm )
250
+ cot = aiscot . ais_to_cot (sample_data_pyAISm )
253
251
254
252
assert cot .tag == "event"
255
253
assert cot .attrib ["type" ] == "a-f-G-I-U-T"
256
254
257
255
258
256
def test_ais_to_cot (sample_data_pyAISm ):
259
257
"""Test converting AIS to CoT."""
260
- cot : bytes = cot_to_xml (sample_data_pyAISm )
258
+ cot : bytes = aiscot . cot_to_xml (sample_data_pyAISm )
261
259
assert b"a-f-S-X-M" in cot
262
260
assert b"MMSI-366892000" in cot
0 commit comments