Skip to content

Commit

Permalink
adds missing NavigationStatus enum attrs and adds missing ShipType (2…
Browse files Browse the repository at this point in the history
…9) (#124)

* adds missing NavigationStatus enum attrs and adds missing ShipType (29)

* prepare version 2.5.8
  • Loading branch information
M0r13n authored Oct 2, 2023
1 parent 6081010 commit 0c859cb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
====================
pyais CHANGELOG
====================
-------------------------------------------------------------------------------
Version 2.5.8 01 Oct 2023
-------------------------------------------------------------------------------
* bug fix: Navigational statuses 9, 10, 13 and Ship type 29
* closes https://github.com/M0r13n/pyais/issues/123
* adds Navigational statuses 9, 10, 13 to NavigationStatus
* adds Ship type 29 to ShipType
-------------------------------------------------------------------------------
Version 2.5.7 29 Jul 2023
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ check-build:
twine check dist/*

type-check:
mypy ./pyais
mypy ./pyais --strict

clean:
rm -rf .mypy_cache
Expand Down
2 changes: 1 addition & 1 deletion pyais/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pyais.tracker import AISTracker, AISTrack

__license__ = 'MIT'
__version__ = '2.5.7'
__version__ = '2.5.8'
__author__ = 'Leon Morten Richter'

__all__ = (
Expand Down
6 changes: 6 additions & 0 deletions pyais/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class NavigationStatus(IntEnum):
Aground = 6
EngagedInFishing = 7
UnderWaySailing = 8
ReservedFutureAmendmentHSC = 9
ReservedFutureAmendmentWIG = 10
PowerDrivenVesselTowingAstern = 11
PowerDrivenVesselPushingAhead = 12
ReservedFutureUse = 13
AISSARTActive = 14
Undefined = 15

Expand Down Expand Up @@ -110,6 +115,7 @@ class ShipType(IntEnum):
WIG_HazardousCategory_C = 23
WIG_HazardousCategory_D = 24
WIG_Reserved = 25
WIG_NoAdditionalInformation = 29
# 30's
Fishing = 30
Towing = 31
Expand Down
14 changes: 14 additions & 0 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import unittest

from pyais import decode, encode_msg
from pyais.constants import NavigationStatus, ManeuverIndicator, ShipType, NavAid, TransmitMode, StationIntervals, \
StationType


class TestConstants(unittest.TestCase):
def test_that_nav_data_values_are_kept_for_all_values(self):
# See: https://github.com/M0r13n/pyais/issues/123
orignal = decode(b"!AIVDM,1,1,,B,15M67FC000G?ufbE`FepT@3n00Sa,0*5C")

for i in range(15):
orignal.status = i
encoded = encode_msg(orignal)
decoded = decode(encoded[0])

self.assertEqual(decoded.status.value, i)

def test_nav_status(self):

self.assertEqual(NavigationStatus(3), NavigationStatus.RestrictedManoeuverability)
self.assertEqual(NavigationStatus(17), NavigationStatus.Undefined)

Expand Down

0 comments on commit 0c859cb

Please sign in to comment.