Skip to content

Commit

Permalink
Added tests for mmsi_to_iso3166_alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
rdgfuentes committed Nov 29, 2024
1 parent dd01a3a commit bcc5a8f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/libs/utils/tests/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from utils.convert import to_float
from utils.convert import mmsi_to_iso3166_alpha3, to_float


class TestConvert(unittest.TestCase):
Expand All @@ -16,6 +16,20 @@ def test_with_invalid_input(self):
with self.assertRaises(ValueError):
to_float("wrong_float")

def test_mmsi_to_iso3166_alpha3_valid(self):
# Assuming mmsi_mid_codes contains {'369': [None, 'USA', None, None]}
result = mmsi_to_iso3166_alpha3('369456789')
self.assertEqual(result, 'USA')

def test_mmsi_to_iso3166_alpha3_invalid_mmsi(self):
result = mmsi_to_iso3166_alpha3('invalid_mmsi')
self.assertIsNone(result)

def test_mmsi_to_iso3166_alpha3_not_in_mid_codes(self):
# Assuming mmsi_mid_codes does not contain '999'
result = mmsi_to_iso3166_alpha3('999456789')
self.assertIsNone(result)


if __name__ == "__main__":
unittest.main()

0 comments on commit bcc5a8f

Please sign in to comment.