def must_equal(self, tar_path, expect, expect_attrs, attrkeys = None): if attrkeys is None: attrkeys = ["size", "sha1", "mode"] m = Manifest_from_walking_unpacked_tar(tar_path, attrkeys) self.assertEqual(m, expect) for path, e_attrs in expect_attrs.items(): self.assertEqual(m.resolve(path).getattrs(), e_attrs)
def test_files_with_contents(self): import os s = os.stat(t_path("files_with_contents.tar")) expect_uid, expect_gid = s.st_uid, s.st_gid m = Manifest_from_walking_unpacked_tar("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, })
def check_visited_paths(self, tar_path, expect): m = Manifest_from_walking_unpacked_tar(tar_path) self.assertEqual(["/".join(path) for path, entries, attrs in m.walk()], expect)
def must_equal(self, tar_path, expect): m = Manifest_from_walking_unpacked_tar(tar_path) self.assertEqual(list(m.paths()), expect)