Example #1
0
 def test_reading(self):
     gdb = PureGitODB(os.path.join(rorepo_dir(), 'objects'))
     
     # we have packs and loose objects, alternates doesn't necessarily exist
     assert 1 < len(gdb.databases()) < 4
     
     # access should be possible
     git_sha = hex_to_bin("5aebcd5cb3340fb31776941d7e4d518a712a8655")
     assert isinstance(gdb.info(git_sha), OInfo)
     assert isinstance(gdb.stream(git_sha), OStream)
     assert gdb.size() > 200
     sha_list = list(gdb.sha_iter())
     assert len(sha_list) == gdb.size()
     
     
     # This is actually a test for compound functionality, but it doesn't 
     # have a separate test module
     # test partial shas
     # this one as uneven and quite short
     assert gdb.partial_to_complete_sha_hex('5aebcd') == hex_to_bin("5aebcd5cb3340fb31776941d7e4d518a712a8655")
     
     # mix even/uneven hexshas
     for i, binsha in enumerate(sha_list[:50]):
         assert gdb.partial_to_complete_sha_hex(bin_to_hex(binsha)[:8-(i%2)]) == binsha
     # END for each sha
     
     self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, "0000")
Example #2
0
    def test_reading(self):
        gdb = PureGitODB(os.path.join(rorepo_dir(), 'objects'))

        # we have packs and loose objects, alternates doesn't necessarily exist
        assert 1 < len(gdb.databases()) < 4

        # access should be possible
        git_sha = hex_to_bin("5aebcd5cb3340fb31776941d7e4d518a712a8655")
        assert isinstance(gdb.info(git_sha), OInfo)
        assert isinstance(gdb.stream(git_sha), OStream)
        assert gdb.size() > 200
        sha_list = list(gdb.sha_iter())
        assert len(sha_list) == gdb.size()

        # This is actually a test for compound functionality, but it doesn't
        # have a separate test module
        # test partial shas
        # this one as uneven and quite short
        assert gdb.partial_to_complete_sha_hex('5aebcd') == hex_to_bin(
            "5aebcd5cb3340fb31776941d7e4d518a712a8655")

        # mix even/uneven hexshas
        for i, binsha in enumerate(sha_list[:50]):
            assert gdb.partial_to_complete_sha_hex(
                bin_to_hex(binsha)[:8 - (i % 2)]) == binsha
        # END for each sha

        self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex,
                              "0000")
Example #3
0
 def setUp(cls):
     """
     Dynamically add a read-only repository to our actual type. This way 
     each test type has its own repository
     """
     if cls.needs_ro_repo:
         if cls is not TestDBBase:
             assert cls.RepoCls is not None, "RepoCls class member must be set in %s" % cls
         cls.rorepo = cls.RepoCls(rorepo_dir())
Example #4
0
 def setUp(cls):
     """
     Dynamically add a read-only repository to our actual type. This way 
     each test type has its own repository
     """
     if cls.needs_ro_repo:
         if cls is not TestDBBase:
             assert cls.RepoCls is not None, "RepoCls class member must be set in %s" % cls
         cls.rorepo = cls.RepoCls(rorepo_dir())