Ejemplo n.º 1
0
    def test_readdir(self):
        all_commits = list(self.repofs._git.all_commits())
        last_commit = all_commits[0]
        contents_of_last = self.repofs._git.directory_contents(last_commit, "")
        contents_of_last_dira = self.repofs._git.directory_contents(
            last_commit, "dir_a")

        self.assertEqual(len(list(self.generate("").readdir())),
                         len(list(self.repofs._git.years)))
        self.assertEqual(len(list(self.generate("2007").readdir())), 12)
        self.assertEqual(len(list(self.generate("2007/10").readdir())),
                         self.generate("2007")._days_per_month(2007)[9])
        self.assertEqual(
            self.generate("2009/10/11/" + last_commit).readdir(),
            contents_of_last + utils.metadata_names())
        self.assertEqual(
            self.generate("2009/10/11/" + last_commit + "/dir_a").readdir(),
            contents_of_last_dira)

        self.assertEqual(len(self.generate("").readdir()), 5)
        self.assertEqual(len(self.generate("2005").readdir()), 12)
        self.assertEqual(len(self.generate("2005/6").readdir()), 30)
        self.assertEqual(len(self.generate("2005/6/7").readdir()), 1)
        self.assertEqual(len(self.generate("2005/6/6").readdir()), 0)
        self.assertEqual(len(self.generate("2005/6/8").readdir()), 0)
        self.assertEqual(len(self.generate("2005/6/29").readdir()), 0)
        self.assertEqual(len(self.generate("2005/6/30").readdir()), 1)
        self.assertEqual(len(self.generate("2005/7/1").readdir()), 2)
        self.assertEqual(len(self.generate("2009/10/11").readdir()), 2)
        self.assertEqual(len(self.generate("2005/6/30").readdir()[0]), 40)
Ejemplo n.º 2
0
    def test_readdir(self):
        all_commits = list(self.repofs_htree._git.all_commits())
        last_commit = all_commits[0]
        contents_of_last = self.repofs_htree._git.directory_contents(
            last_commit, "")
        contents_of_last_dira = self.repofs_htree._git.directory_contents(
            last_commit, "dir_a")

        self.assertGreater(len(list(self.generate("", False).readdir())), 1)
        self.assertEqual(len(list(self.generate("", False).readdir())), 8)
        self.assertEqual(list(self.generate("", False).readdir()), all_commits)
        self.assertEqual(list(self.generate(last_commit, False).readdir()),
                         list(contents_of_last) + utils.metadata_names())
        self.assertEqual(
            list(self.generate(last_commit + "/dir_a", False).readdir()),
            list(contents_of_last_dira))

        # hash trees
        self.assertEqual(len(list(self.generate("", True).readdir())), 256)
        self.assertEqual(len(list(self.generate("aa", True).readdir())), 256)
        self.assertEqual(len(list(self.generate("aa/bb", True).readdir())),
                         256)
        self.assertGreaterEqual(
            len(
                list(
                    self.generate(self.to_hash_path(last_commit),
                                  True).readdir())), 1)
        self.assertEqual(
            next(
                self.generate(self.to_hash_path(last_commit), True).readdir()),
            last_commit)
        self.assertEqual(
            self.generate(
                self.to_hash_path(last_commit) + "/" + last_commit,
                True).readdir(), contents_of_last + utils.metadata_names())
        self.assertEqual(
            self.generate(
                self.to_hash_path(last_commit) + "/" + last_commit + "/dir_a",
                True).readdir(), list(contents_of_last_dira))
Ejemplo n.º 3
0
 def test_metadata_names(self):
     self.assertEqual(metadata_names(), [
         ".git-parents", ".git-descendants", ".git-names", ".author",
         ".author-email"
     ])
Ejemplo n.º 4
0
 def _get_metadata_names(self):
     return utils.metadata_names()