Skip to content

Commit

Permalink
stat: add .last_updated to returned namedtuple
Browse files Browse the repository at this point in the history
  • Loading branch information
OddBloke committed Sep 27, 2022
1 parent 5f8cb2e commit b8a3e69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ def _get_base_url(self, url):
"is_dir",
"children",
"repo",
"last_updated",
],
)

Expand Down Expand Up @@ -897,6 +898,7 @@ def stat(self, pathobj):
is_dir=is_dir,
children=children,
repo=jsn.get("repo", None),
last_updated=dateutil.parser.parse(jsn["lastUpdated"]),
)

return stat
Expand Down Expand Up @@ -1594,6 +1596,7 @@ def stat(self, pathobj=None):
md5 -- MD5 digest of the file
is_dir -- 'True' if path is a directory
children -- list of children names
last_updated -- artifact update time
"""
pathobj = pathobj or self
return self._accessor.stat(pathobj=pathobj)
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_artifactory_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ def test_stat(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(stats.created_by, "someuser")
self.assertEqual(stats.modified_by, "anotheruser")
self.assertEqual(stats.mime_type, "application/octet-stream")
Expand Down Expand Up @@ -532,6 +535,9 @@ def test_stat(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-18T15:35:29.361+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-18T15:35:29.361+04:00")
)
self.assertEqual(stats.created_by, None)
self.assertEqual(stats.modified_by, None)
self.assertEqual(stats.mime_type, None)
Expand Down Expand Up @@ -594,6 +600,9 @@ def test_stat_no_sha256(self):
self.assertEqual(
stats.mtime, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(
stats.last_updated, dateutil.parser.parse("2014-02-24T21:20:36.000+04:00")
)
self.assertEqual(stats.created_by, "someuser")
self.assertEqual(stats.modified_by, "anotheruser")
self.assertEqual(stats.mime_type, "application/octet-stream")
Expand Down

0 comments on commit b8a3e69

Please sign in to comment.