Пример #1
0
 def must_equal(self, tar_path, expect, expect_attrs, attrkeys = None):
     if attrkeys is None:
         attrkeys = ["size", "sha1", "mode"]
     m = ManifestTarWalker().build(t_path(tar_path), attrkeys = attrkeys)
     self.assertEqual(m, expect)
     for path, e_attrs in expect_attrs.items():
         self.assertEqual(m.resolve(path).getattrs(), e_attrs)
Пример #2
0
 def test_files_with_contents(self):
     import tarfile
     tf = tarfile.open(t_path("files_with_contents.tar"), errorlevel=1)
     ti = tf.next()
     expect_uid, expect_gid = ti.uid, ti.gid
     tf.close()
     m = ManifestTarWalker().build(t_path("files_with_contents.tar"))
     self.assertEqual(m, {
         "foo": {},
         "bar": {"baz": {}},
         "symlink_to_bar_baz": {}
     })
     self.assertEqual(m.resolve("foo").getattrs(), {
         "size": 12,
         "sha1": "fc6da897c87c7b9c3b67d1d5af32085e561db793",
         "mode": 0o100644,
         "uid": expect_uid,
         "gid": expect_gid,
     })
     self.assertEqual(m.resolve("bar").getattrs(), {
         "mode": 0o040755,
         "uid": expect_uid,
         "gid": expect_gid,
     })
     self.assertEqual(m.resolve("bar/baz").getattrs(), {
         "size": 12,
         "sha1": "7508a86c26bcda1d3f298f67de33f7c48a3fe047",
         "mode": 0o100644,
         "uid": expect_uid,
         "gid": expect_gid,
     })
     self.assertEqual(m.resolve("symlink_to_bar_baz").getattrs(), {
         "mode": 0o120777,
         "uid": expect_uid,
         "gid": expect_gid,
     })