Skip to content

Commit f982cae

Browse files
committed
fixing test imports
1 parent a883b8b commit f982cae

File tree

4 files changed

+38
-52
lines changed

4 files changed

+38
-52
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AISCOT is a software solution designed to monitor and analyze maritime surveilla
1111
- Compatibility with ATAK, WinTAK, iTAK, TAK Server & TAKX
1212
- Support for RF AIS transmissions, local NMEA, and Internet AIS aggregators
1313
- Display of AIS data with icons, attitude, type, track, bearing, speed, callsign, and more
14-
- Support
14+
- Support for [United States Department of Transportation (US DOT) SeaVision](https://seavision.volpe.dot.gov/)
1515

1616
## Documentation
1717

src/aiscot/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
DEFAULT_SHIP_DB_FILE,
3030
)
3131

32-
from .functions import create_tasks, cot_to_xml # NOQA
32+
from .functions import create_tasks, cot_to_xml, ais_to_cot # NOQA
3333

3434
from .ais_functions import get_known_craft # NOQA
3535

tests/test_ais_functions.py

+21-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright 2023 Greg Albrecht <[email protected]>
4+
# Copyright Sensors & Signals LLC https://www.snstac.com/
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -20,21 +20,7 @@
2020

2121
import pytest
2222

23-
from aiscot.constants import DEFAULT_MID_DB_FILE, DEFAULT_SHIP_DB_FILE
24-
25-
from aiscot.ais_functions import (
26-
get_aton,
27-
get_mid,
28-
get_known_craft,
29-
get_sar,
30-
get_crs,
31-
get_shipname,
32-
)
33-
34-
35-
__author__ = "Greg Albrecht <[email protected]>"
36-
__copyright__ = "Copyright 2023 Greg Albrecht"
37-
__license__ = "Apache License, Version 2.0"
23+
import aiscot
3824

3925

4026
@pytest.fixture
@@ -121,38 +107,40 @@ def sample_aton():
121107
def test_get_mid(sample_data_pyAISm):
122108
"""Test that git_mid returns the country MID corresponding for a given MMSI."""
123109
mmsi = sample_data_pyAISm.get("mmsi")
124-
country = get_mid(mmsi)
110+
country = aiscot.ais_functions.get_mid(mmsi)
125111
assert country == "United States of America"
126112

127113

128114
def test_get_known_craft():
129-
"""Test reading know craft CSV with `get_known_craft()`."""
130-
known_craft = get_known_craft("tests/data/test_known_craft.csv")
115+
"""Test reading know craft CSV with `aiscot.ais_functions.get_known_craft()`."""
116+
known_craft = aiscot.ais_functions.get_known_craft(
117+
"tests/data/test_known_craft.csv"
118+
)
131119
assert known_craft[0].get("MMSI") == "366892000"
132120

133121

134122
def test_get_aton(sample_aton):
135-
"""Test Aid to Naviation vessels with `get_aton()`."""
123+
"""Test Aid to Naviation vessels with `aiscot.ais_functions.get_aton()`."""
136124
mmsi = sample_aton.get("mmsi")
137-
assert get_aton(mmsi) is True
125+
assert aiscot.ais_functions.get_aton(mmsi) is True
138126

139127

140128
def test_get_crs():
141-
"""Test CRS vessels with `get_crs()`."""
142-
assert get_crs("3669123") is True
143-
assert get_crs("003369000") is True
144-
assert get_crs("938852000") is False
129+
"""Test CRS vessels with `aiscot.ais_functions.get_crs()`."""
130+
assert aiscot.ais_functions.get_crs("3669123") is True
131+
assert aiscot.ais_functions.get_crs("003369000") is True
132+
assert aiscot.ais_functions.get_crs("938852000") is False
145133

146134

147135
def test_get_sar():
148-
"""Test SAR vessels with `get_sar()`."""
149-
assert get_sar("111892000") is True
150-
assert get_sar("303862000") is True
151-
assert get_sar("338852000") is True
152-
assert get_sar("938852000") is False
136+
"""Test SAR vessels with `aiscot.ais_functions.get_sar()`."""
137+
assert aiscot.ais_functions.get_sar("111892000") is True
138+
assert aiscot.ais_functions.get_sar("303862000") is True
139+
assert aiscot.ais_functions.get_sar("338852000") is True
140+
assert aiscot.ais_functions.get_sar("938852000") is False
153141

154142

155143
def test_get_shipname():
156-
"""Test getting shipname from db using `get_shipname()`."""
157-
assert get_shipname("303990000") == "USCG EAGLE"
158-
assert get_shipname("938852000") == ""
144+
"""Test getting shipname from db using `aiscot.ais_functions.get_shipname()`."""
145+
assert aiscot.ais_functions.get_shipname("303990000") == "USCG EAGLE"
146+
assert aiscot.ais_functions.get_shipname("938852000") == ""

tests/test_functions.py

+15-17
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
import pytest
2525

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
2927

3028

3129
@pytest.fixture
@@ -115,11 +113,11 @@ def sample_known_craft():
115113
366892000,TACO_01,a-f-S-T-A-C-O,
116114
"""
117115
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)
119117

120118

121119
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)
123121
assert isinstance(cot, ET.Element)
124122
assert cot.tag == "event"
125123
assert cot.attrib["version"] == "2.0"
@@ -154,7 +152,7 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft):
154152
or [{}]
155153
)[0]
156154

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)
158156

159157
assert isinstance(cot, ET.Element)
160158
assert cot.tag == "event"
@@ -181,9 +179,9 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft):
181179

182180

183181
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."""
185183
assert (
186-
ais_to_cot(
184+
aiscot.ais_to_cot(
187185
{
188186
"mmsi": 366892000,
189187
"lon": 0,
@@ -193,7 +191,7 @@ def test_ais_to_cot_none():
193191
is None
194192
)
195193
assert (
196-
ais_to_cot(
194+
aiscot.ais_to_cot(
197195
{
198196
"mmsi": 366892000,
199197
"lon": -122.51208,
@@ -203,7 +201,7 @@ def test_ais_to_cot_none():
203201
is None
204202
)
205203
assert (
206-
ais_to_cot(
204+
aiscot.ais_to_cot(
207205
{
208206
"mmsi": "",
209207
"lon": -122.51208,
@@ -212,23 +210,23 @@ def test_ais_to_cot_none():
212210
)
213211
is None
214212
)
215-
assert ais_to_cot({}) is None
213+
assert aiscot.ais_to_cot({}) is None
216214

217215

218216
def test_ais_to_cot_dont_ignore_aton(sample_aton):
219217
"""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
221219

222220

223221
def test_ais_to_cot_ignore_aton(sample_aton):
224222
"""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
226224

227225

228226
def test_ais_to_cot_shipname(sample_data_pyAISm):
229227
"""Test converting AIS to CoT with a known shipname."""
230228
sample_data_pyAISm["mmsi"] = "303990000"
231-
cot = ais_to_cot(sample_data_pyAISm)
229+
cot = aiscot.ais_to_cot(sample_data_pyAISm)
232230

233231
detail = cot.findall("detail")
234232
assert detail[0].tag == "detail"
@@ -240,7 +238,7 @@ def test_ais_to_cot_shipname(sample_data_pyAISm):
240238
def test_ais_to_cot_sar(sample_data_pyAISm):
241239
"""Test converting AIS to CoT for a SAR vessel."""
242240
sample_data_pyAISm["mmsi"] = "303862000"
243-
cot = ais_to_cot(sample_data_pyAISm)
241+
cot = aiscot.ais_to_cot(sample_data_pyAISm)
244242

245243
assert cot.tag == "event"
246244
assert cot.attrib["type"] == "a-f-S-X-L"
@@ -249,14 +247,14 @@ def test_ais_to_cot_sar(sample_data_pyAISm):
249247
def test_ais_to_cot_crs(sample_data_pyAISm):
250248
"""Test converting AIS to CoT for a CRS vessel."""
251249
sample_data_pyAISm["mmsi"] = "3669123"
252-
cot = ais_to_cot(sample_data_pyAISm)
250+
cot = aiscot.ais_to_cot(sample_data_pyAISm)
253251

254252
assert cot.tag == "event"
255253
assert cot.attrib["type"] == "a-f-G-I-U-T"
256254

257255

258256
def test_ais_to_cot(sample_data_pyAISm):
259257
"""Test converting AIS to CoT."""
260-
cot: bytes = cot_to_xml(sample_data_pyAISm)
258+
cot: bytes = aiscot.cot_to_xml(sample_data_pyAISm)
261259
assert b"a-f-S-X-M" in cot
262260
assert b"MMSI-366892000" in cot

0 commit comments

Comments
 (0)