diff options
author | Yobmod <yobmod@gmail.com> | 2021-06-17 17:38:42 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-06-17 17:38:42 +0100 |
commit | 3a84459c6a5a1d8a81e4a51189091ef135e1776e (patch) | |
tree | e1207dbe034f82deacbb76369716779608e7056d /test/test_repo.py | |
parent | df39446bb7b90ab9436fa3a76f6d4182c2a47da2 (diff) | |
parent | 636f77bf8d58a482df0bde8c0a6a8828950a0788 (diff) | |
download | gitpython-3a84459c6a5a1d8a81e4a51189091ef135e1776e.tar.gz |
add travis
Diffstat (limited to 'test/test_repo.py')
-rw-r--r-- | test/test_repo.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_repo.py b/test/test_repo.py index 8dc17833..8aced94d 100644 --- a/test/test_repo.py +++ b/test/test_repo.py @@ -414,6 +414,16 @@ class TestRepo(TestBase): def test_tag(self): assert self.rorepo.tag('refs/tags/0.1.5').commit + def test_tag_to_full_tag_path(self): + tags = ['0.1.5', 'tags/0.1.5', 'refs/tags/0.1.5'] + value_errors = [] + for tag in tags: + try: + self.rorepo.tag(tag) + except ValueError as valueError: + value_errors.append(valueError.args[0]) + self.assertEqual(value_errors, []) + def test_archive(self): tmpfile = tempfile.mktemp(suffix='archive-test') with open(tmpfile, 'wb') as stream: @@ -979,6 +989,34 @@ class TestRepo(TestBase): for i, j in itertools.permutations([c1, 'ffffff', ''], r=2): self.assertRaises(GitCommandError, repo.is_ancestor, i, j) + def test_is_valid_object(self): + repo = self.rorepo + commit_sha = 'f6aa8d1' + blob_sha = '1fbe3e4375' + tree_sha = '960b40fe36' + tag_sha = '42c2f60c43' + + # Check for valid objects + self.assertTrue(repo.is_valid_object(commit_sha)) + self.assertTrue(repo.is_valid_object(blob_sha)) + self.assertTrue(repo.is_valid_object(tree_sha)) + self.assertTrue(repo.is_valid_object(tag_sha)) + + # Check for valid objects of specific type + self.assertTrue(repo.is_valid_object(commit_sha, 'commit')) + self.assertTrue(repo.is_valid_object(blob_sha, 'blob')) + self.assertTrue(repo.is_valid_object(tree_sha, 'tree')) + self.assertTrue(repo.is_valid_object(tag_sha, 'tag')) + + # Check for invalid objects + self.assertFalse(repo.is_valid_object(b'1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a', 'blob')) + + # Check for invalid objects of specific type + self.assertFalse(repo.is_valid_object(commit_sha, 'blob')) + self.assertFalse(repo.is_valid_object(blob_sha, 'commit')) + self.assertFalse(repo.is_valid_object(tree_sha, 'commit')) + self.assertFalse(repo.is_valid_object(tag_sha, 'commit')) + @with_rw_directory def test_git_work_tree_dotgit(self, rw_dir): """Check that we find .git as a worktree file and find the worktree |