You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
939B

  1. # test_repo.py
  2. # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
  3. #
  4. # This module is part of GitPython and is released under
  5. # the BSD License: http://www.opensource.org/licenses/bsd-license.php
  6. from git.db import GitCmdObjectDB
  7. from git.exc import BadObject
  8. from git.test.lib import TestBase
  9. from git.util import bin_to_hex
  10. import os.path as osp
  11. class TestDB(TestBase):
  12. def test_base(self):
  13. gdb = GitCmdObjectDB(osp.join(self.rorepo.git_dir, 'objects'), self.rorepo.git)
  14. # partial to complete - works with everything
  15. hexsha = bin_to_hex(gdb.partial_to_complete_sha_hex("0.1.6"))
  16. assert len(hexsha) == 40
  17. assert bin_to_hex(gdb.partial_to_complete_sha_hex(hexsha[:20])) == hexsha
  18. # fails with BadObject
  19. for invalid_rev in ("0000", "bad/ref", "super bad"):
  20. self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, invalid_rev)