From f982caecd9e43b49b31bde1cffffa25b2b417056 Mon Sep 17 00:00:00 2001 From: Greg Albrecht Date: Mon, 3 Feb 2025 09:49:40 -0800 Subject: [PATCH] fixing test imports --- README.md | 2 +- src/aiscot/__init__.py | 2 +- tests/test_ais_functions.py | 54 +++++++++++++++---------------------- tests/test_functions.py | 32 +++++++++++----------- 4 files changed, 38 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 240250c..f413071 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ AISCOT is a software solution designed to monitor and analyze maritime surveilla - Compatibility with ATAK, WinTAK, iTAK, TAK Server & TAKX - Support for RF AIS transmissions, local NMEA, and Internet AIS aggregators - Display of AIS data with icons, attitude, type, track, bearing, speed, callsign, and more -- Support +- Support for [United States Department of Transportation (US DOT) SeaVision](https://seavision.volpe.dot.gov/) ## Documentation diff --git a/src/aiscot/__init__.py b/src/aiscot/__init__.py index a2b82b3..45cc416 100644 --- a/src/aiscot/__init__.py +++ b/src/aiscot/__init__.py @@ -29,7 +29,7 @@ DEFAULT_SHIP_DB_FILE, ) -from .functions import create_tasks, cot_to_xml # NOQA +from .functions import create_tasks, cot_to_xml, ais_to_cot # NOQA from .ais_functions import get_known_craft # NOQA diff --git a/tests/test_ais_functions.py b/tests/test_ais_functions.py index abbba3e..7f02508 100644 --- a/tests/test_ais_functions.py +++ b/tests/test_ais_functions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright 2023 Greg Albrecht +# Copyright Sensors & Signals LLC https://www.snstac.com/ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,21 +20,7 @@ import pytest -from aiscot.constants import DEFAULT_MID_DB_FILE, DEFAULT_SHIP_DB_FILE - -from aiscot.ais_functions import ( - get_aton, - get_mid, - get_known_craft, - get_sar, - get_crs, - get_shipname, -) - - -__author__ = "Greg Albrecht " -__copyright__ = "Copyright 2023 Greg Albrecht" -__license__ = "Apache License, Version 2.0" +import aiscot @pytest.fixture @@ -121,38 +107,40 @@ def sample_aton(): def test_get_mid(sample_data_pyAISm): """Test that git_mid returns the country MID corresponding for a given MMSI.""" mmsi = sample_data_pyAISm.get("mmsi") - country = get_mid(mmsi) + country = aiscot.ais_functions.get_mid(mmsi) assert country == "United States of America" def test_get_known_craft(): - """Test reading know craft CSV with `get_known_craft()`.""" - known_craft = get_known_craft("tests/data/test_known_craft.csv") + """Test reading know craft CSV with `aiscot.ais_functions.get_known_craft()`.""" + known_craft = aiscot.ais_functions.get_known_craft( + "tests/data/test_known_craft.csv" + ) assert known_craft[0].get("MMSI") == "366892000" def test_get_aton(sample_aton): - """Test Aid to Naviation vessels with `get_aton()`.""" + """Test Aid to Naviation vessels with `aiscot.ais_functions.get_aton()`.""" mmsi = sample_aton.get("mmsi") - assert get_aton(mmsi) is True + assert aiscot.ais_functions.get_aton(mmsi) is True def test_get_crs(): - """Test CRS vessels with `get_crs()`.""" - assert get_crs("3669123") is True - assert get_crs("003369000") is True - assert get_crs("938852000") is False + """Test CRS vessels with `aiscot.ais_functions.get_crs()`.""" + assert aiscot.ais_functions.get_crs("3669123") is True + assert aiscot.ais_functions.get_crs("003369000") is True + assert aiscot.ais_functions.get_crs("938852000") is False def test_get_sar(): - """Test SAR vessels with `get_sar()`.""" - assert get_sar("111892000") is True - assert get_sar("303862000") is True - assert get_sar("338852000") is True - assert get_sar("938852000") is False + """Test SAR vessels with `aiscot.ais_functions.get_sar()`.""" + assert aiscot.ais_functions.get_sar("111892000") is True + assert aiscot.ais_functions.get_sar("303862000") is True + assert aiscot.ais_functions.get_sar("338852000") is True + assert aiscot.ais_functions.get_sar("938852000") is False def test_get_shipname(): - """Test getting shipname from db using `get_shipname()`.""" - assert get_shipname("303990000") == "USCG EAGLE" - assert get_shipname("938852000") == "" + """Test getting shipname from db using `aiscot.ais_functions.get_shipname()`.""" + assert aiscot.ais_functions.get_shipname("303990000") == "USCG EAGLE" + assert aiscot.ais_functions.get_shipname("938852000") == "" diff --git a/tests/test_functions.py b/tests/test_functions.py index 85e59cf..8f1921e 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -23,9 +23,7 @@ import pytest -from aiscot.ais_functions import read_known_craft_fd -from aiscot.constants import DEFAULT_MID_DB_FILE, DEFAULT_SHIP_DB_FILE -from aiscot.functions import ais_to_cot, cot_to_xml +import aiscot @pytest.fixture @@ -115,11 +113,11 @@ def sample_known_craft(): 366892000,TACO_01,a-f-S-T-A-C-O, """ csv_fd = io.StringIO(sample_csv) - return read_known_craft_fd(csv_fd) + return aiscot.ais_functions.read_known_craft_fd(csv_fd) def test_ais_to_cot(sample_data_pyAISm): - cot = ais_to_cot(sample_data_pyAISm) + cot = aiscot.ais_to_cot(sample_data_pyAISm) assert isinstance(cot, ET.Element) assert cot.tag == "event" assert cot.attrib["version"] == "2.0" @@ -154,7 +152,7 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft): or [{}] )[0] - cot = ais_to_cot(sample_data_pyAISm, known_craft=known_craft) + cot = aiscot.ais_to_cot(sample_data_pyAISm, known_craft=known_craft) assert isinstance(cot, ET.Element) assert cot.tag == "event" @@ -181,9 +179,9 @@ def test_ais_to_cot_with_known_craft(sample_data_pyAISm, sample_known_craft): def test_ais_to_cot_none(): - """Test that `ais_to_cot()` only renders valid input data.""" + """Test that `aiscot.ais_to_cot()` only renders valid input data.""" assert ( - ais_to_cot( + aiscot.ais_to_cot( { "mmsi": 366892000, "lon": 0, @@ -193,7 +191,7 @@ def test_ais_to_cot_none(): is None ) assert ( - ais_to_cot( + aiscot.ais_to_cot( { "mmsi": 366892000, "lon": -122.51208, @@ -203,7 +201,7 @@ def test_ais_to_cot_none(): is None ) assert ( - ais_to_cot( + aiscot.ais_to_cot( { "mmsi": "", "lon": -122.51208, @@ -212,23 +210,23 @@ def test_ais_to_cot_none(): ) is None ) - assert ais_to_cot({}) is None + assert aiscot.ais_to_cot({}) is None def test_ais_to_cot_dont_ignore_aton(sample_aton): """Test ignoring Aids to Naviation (ATON).""" - assert ais_to_cot(sample_aton, {"IGNORE_ATON": False}) is not None + assert aiscot.ais_to_cot(sample_aton, {"IGNORE_ATON": False}) is not None def test_ais_to_cot_ignore_aton(sample_aton): """Test ignoring Aids to Naviation (ATON).""" - assert ais_to_cot(sample_aton, {"IGNORE_ATON": True}) is None + assert aiscot.ais_to_cot(sample_aton, {"IGNORE_ATON": True}) is None def test_ais_to_cot_shipname(sample_data_pyAISm): """Test converting AIS to CoT with a known shipname.""" sample_data_pyAISm["mmsi"] = "303990000" - cot = ais_to_cot(sample_data_pyAISm) + cot = aiscot.ais_to_cot(sample_data_pyAISm) detail = cot.findall("detail") assert detail[0].tag == "detail" @@ -240,7 +238,7 @@ def test_ais_to_cot_shipname(sample_data_pyAISm): def test_ais_to_cot_sar(sample_data_pyAISm): """Test converting AIS to CoT for a SAR vessel.""" sample_data_pyAISm["mmsi"] = "303862000" - cot = ais_to_cot(sample_data_pyAISm) + cot = aiscot.ais_to_cot(sample_data_pyAISm) assert cot.tag == "event" assert cot.attrib["type"] == "a-f-S-X-L" @@ -249,7 +247,7 @@ def test_ais_to_cot_sar(sample_data_pyAISm): def test_ais_to_cot_crs(sample_data_pyAISm): """Test converting AIS to CoT for a CRS vessel.""" sample_data_pyAISm["mmsi"] = "3669123" - cot = ais_to_cot(sample_data_pyAISm) + cot = aiscot.ais_to_cot(sample_data_pyAISm) assert cot.tag == "event" assert cot.attrib["type"] == "a-f-G-I-U-T" @@ -257,6 +255,6 @@ def test_ais_to_cot_crs(sample_data_pyAISm): def test_ais_to_cot(sample_data_pyAISm): """Test converting AIS to CoT.""" - cot: bytes = cot_to_xml(sample_data_pyAISm) + cot: bytes = aiscot.cot_to_xml(sample_data_pyAISm) assert b"a-f-S-X-M" in cot assert b"MMSI-366892000" in cot