Skip to content

Commit

Permalink
add datetime test for snx_time_to_pydatetime
Browse files Browse the repository at this point in the history
  • Loading branch information
umma-zannat committed Aug 12, 2024
1 parent dfa6c05 commit feac892
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from gnssanalysis import gn_datetime
from datetime import datetime as _datetime
import numpy as np


Expand All @@ -26,3 +27,22 @@ def test_gpsdate(self):
np.testing.assert_array_equal(yds_datetime, np.asarray(["2000-01-01T00:00:00"], dtype="datetime64[s]"))
yds_yds = gn_datetime.datetime2yydoysec(yds_datetime)
np.testing.assert_array_equal(yds_yds, yds)


class TestSNXTimeConversion(unittest.TestCase):

def test_conversion(self):
# Test cases in the format (snx_time, expected_datetime)
test_cases = [
('24:001:00000', _datetime(2024, 1, 1, 0, 0, 0)),
('99:365:86399', _datetime(1999, 12, 31, 23, 59, 59)),
('00:001:00000', _datetime(2000, 1, 1, 0, 0, 0)),
('2024:185:11922', _datetime(2024, 7, 3, 3, 18, 42)),
('1970:001:00000', _datetime(1970, 1, 1, 0, 0, 0)),
('75:365:86399', _datetime(1975, 12, 31, 23, 59, 59)),
]

for snx_time, expected in test_cases:
with self.subTest(snx_time=snx_time):
self.assertEqual(gn_datetime.snx_time_to_pydatetime(snx_time), expected)

0 comments on commit feac892

Please sign in to comment.