diff --git a/swh/storage/tests/storage_data.py b/swh/storage/tests/storage_data.py --- a/swh/storage/tests/storage_data.py +++ b/swh/storage/tests/storage_data.py @@ -199,7 +199,9 @@ 'fullname': b'Nicolas Dandrimont ', }, 'date': { - 'timestamp': 1234567890, + 'timestamp': { + 'seconds': 1234567890, + 'microseconds': 0}, 'offset': 120, 'negative_utc': False, }, @@ -209,7 +211,9 @@ 'fullname': b'St\xc3fano Zacchiroli ' }, 'committer_date': { - 'timestamp': 1123456789, + 'timestamp': { + 'seconds': 1123456789, + 'microseconds': 0}, 'offset': 0, 'negative_utc': True, }, @@ -253,7 +257,9 @@ 'fullname': b'tony ', }, 'committer_date': { - 'timestamp': 1123456789, + 'timestamp': { + 'seconds': 1123456789, + 'microseconds': 0}, 'offset': 0, 'negative_utc': False, }, @@ -287,7 +293,9 @@ 'fullname': b'tony ', }, 'committer_date': { - 'timestamp': 1127351742, + 'timestamp': { + 'seconds': 1127351742, + 'microseconds': 0}, 'offset': 0, 'negative_utc': False, }, @@ -389,7 +397,9 @@ 'fullname': b'olasd ', }, 'date': { - 'timestamp': 1234567890, + 'timestamp': { + 'seconds': 1234567890, + 'microseconds': 0}, 'offset': 42, 'negative_utc': False, }, @@ -408,7 +418,9 @@ 'fullname': b'tony ', }, 'date': { - 'timestamp': 1634366813, + 'timestamp': { + 'seconds': 1634366813, + 'microseconds': 0}, 'offset': -120, 'negative_utc': False, }, @@ -427,7 +439,9 @@ 'fullname': b'tony ', }, 'date': { - 'timestamp': 1634336813, + 'timestamp': { + 'seconds': 1634336813, + 'microseconds': 0}, 'offset': 0, 'negative_utc': False, }, diff --git a/swh/storage/tests/test_converters.py b/swh/storage/tests/test_converters.py --- a/swh/storage/tests/test_converters.py +++ b/swh/storage/tests/test_converters.py @@ -12,6 +12,51 @@ def setUp(self): self.maxDiff = None + def test_date_to_db(self): + date_to_db = converters.date_to_db + assert date_to_db(None) == { + "timestamp": None, "offset": 0, "neg_utc_offset": None} + + assert date_to_db({ + "timestamp": 1234567890, + "offset": 120, + "negative_utc": False, + }) == { + "timestamp": "2009-02-13T23:31:30+00:00", + "offset": 120, + "neg_utc_offset": False, + } + + assert date_to_db({ + "timestamp": 1123456789, + "offset": 0, + "negative_utc": True, + }) == { + "timestamp": "2005-08-07T23:19:49+00:00", + "offset": 0, + "neg_utc_offset": True, + } + + assert date_to_db({ + "timestamp": 1234567890, + "offset": 42, + "negative_utc": False, + }) == { + "timestamp": "2009-02-13T23:31:30+00:00", + "offset": 42, + "neg_utc_offset": False, + } + + assert date_to_db({ + "timestamp": 1634366813, + "offset": -120, + "negative_utc": False, + }) == { + "timestamp": "2021-10-16T06:46:53+00:00", + "offset": -120, + "neg_utc_offset": False, + } + def test_db_to_author(self): # when actual_author = converters.db_to_author(