|
@@ -1,5 +1,6 @@ |
|
|
#!/usr/bin/env python |
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
|
|
|
|
import stat |
|
|
import sys |
|
|
import sys |
|
|
import logging |
|
|
import logging |
|
|
|
|
|
|
|
@@ -1686,7 +1687,31 @@ class _TestCases(unittest.TestCase): |
|
|
self.assertEqual(ObjectStore.makehash('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', strict=False), 'sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e') |
|
|
self.assertEqual(ObjectStore.makehash('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', strict=False), 'sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e') |
|
|
self.assertEqual(ObjectStore.makehash('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', strict=False), 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') |
|
|
self.assertEqual(ObjectStore.makehash('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', strict=False), 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') |
|
|
|
|
|
|
|
|
def test_enumeratedir(self): |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
|
def statmock(fname): |
|
|
|
|
|
fname = pathlib.Path(fname) |
|
|
|
|
|
fnameparts = fname.parts |
|
|
|
|
|
subdiridx = fnameparts.index('subdir') |
|
|
|
|
|
|
|
|
|
|
|
_stats = { |
|
|
|
|
|
# repr on os.stat_result doesn't work |
|
|
|
|
|
# (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) |
|
|
|
|
|
|
|
|
|
|
|
'test.txt': os.stat_result((stat.S_IROTH|stat.S_IRGRP|stat.S_IWUSR|stat.S_IRUSR|stat.S_IFREG, 10, 100, 1, 100, 100, 15, 1654166365, 1558388856.000000, 1663133775)), |
|
|
|
|
|
'newfile.txt': os.stat_result((stat.S_IROTH|stat.S_IRGRP|stat.S_IWUSR|stat.S_IRUSR|stat.S_IFREG, 10, 100, 1, 100, 100, 19, 1659652579, 1658982768.041291, 1663133775)), |
|
|
|
|
|
'sample.data.sqlite3': os.stat_result((stat.S_IROTH|stat.S_IRGRP|stat.S_IWUSR|stat.S_IRUSR|stat.S_IFREG, 10, 100, 1, 100, 100, 57344, 1663133777, 1663133777.529757, 1663133777)), |
|
|
|
|
|
't': os.stat_result((stat.S_IFDIR, 0, 0, 0, 0, 0, 0, 0, 0, 0)), |
|
|
|
|
|
'z.jpg': os.stat_result((stat.S_IROTH|stat.S_IRGRP|stat.S_IWUSR|stat.S_IRUSR|stat.S_IFREG, 10, 100, 1, 100, 100, 332, 1661553878, 1661551130.361235, 1663134325)), |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
subpath = '/'.join(fnameparts[subdiridx + 1:]) |
|
|
|
|
|
return _stats[subpath] |
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('os.stat') |
|
|
|
|
|
def test_enumeratedir(self, statmock): |
|
|
|
|
|
statmock.side_effect = self.statmock |
|
|
|
|
|
|
|
|
files = enumeratedir(self.tempdir, self.created_by_ref) |
|
|
files = enumeratedir(self.tempdir, self.created_by_ref) |
|
|
ftest = [ x for x in files if x.filename == 'test.txt' ][0] |
|
|
ftest = [ x for x in files if x.filename == 'test.txt' ][0] |
|
|
fname = 'test.txt' |
|
|
fname = 'test.txt' |
|
|