Skip to content

Commit

Permalink
chore: update test_dso.py to workaround datetime with different pythons
Browse files Browse the repository at this point in the history
  • Loading branch information
jdstrand committed Aug 18, 2023
1 parent b6d98d7 commit a475535
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test_dso.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def test_getOCIsForNamespace(self, mock_post, mock_ednLoadAsDict):
"image": {
"docker.image/digest": "sha256:af27abadb0a5e58b01e58806a02aca8c46d4c2b0823d6077d13de7ade017e9a9",
"docker.image/created-at": datetime.datetime(
2023, 8, 8, 9, 9, 9, tzinfo=datetime.timezone.utc
2023, 8, 7, 6, 5, 4, tzinfo=datetime.timezone.utc
),
"docker.image/tags": [
"1.0-valid-tag",
Expand All @@ -407,7 +407,17 @@ def test_getOCIsForNamespace(self, mock_post, mock_ednLoadAsDict):
res = dsr.getOCIsForNamespace("valid-repo")
self.assertEqual(1, len(res))
self.assertEqual("1.0-valid-tag", res[0][0])
self.assertEqual(1691503749, res[0][1])

# should be able to do #self.assertEqual(1691503749, res[0][1]) but
# circleci's python gives different epoch (weird). Confirm the datetime
# object is correct
resdt = datetime.datetime.fromtimestamp(res[0][1])
self.assertEqual(2023, resdt.year)
self.assertEqual(8, resdt.month)
self.assertEqual(7, resdt.day)
self.assertEqual(6, resdt.hour)
self.assertEqual(5, resdt.minute)
self.assertEqual(4, resdt.second)

# no date
mock_post.return_value = self._mock_response_for_dso(content="edn-doc")
Expand Down

0 comments on commit a475535

Please sign in to comment.