|
| 1 | +import base |
| 2 | +from expecter import expect |
| 3 | +import github3 |
| 4 | +from github3 import Commit, Blob, Reference, Tag, Tree, Hash, GitObject |
| 5 | + |
| 6 | + |
| 7 | +class TestGit(base.BaseTest): |
| 8 | + def setUp(self): |
| 9 | + super(TestGit, self).setUp() |
| 10 | + self.todor = self.g.repository(self.sigm, self.todo) |
| 11 | + |
| 12 | + def test_blob(self): |
| 13 | + r = self.todor |
| 14 | + blob = r.blob('f737918b90118a6aea991f89f444b150a2360393') |
| 15 | + expect(blob).isinstance(Blob) |
| 16 | + self.assertAreNotNone(blob, 'content', 'decoded', 'encoding', 'sha', |
| 17 | + 'sized') |
| 18 | + |
| 19 | + with expect.raises(github3.GitHubError): |
| 20 | + r.create_blob('Foo bar bogus', 'utf-8') |
| 21 | + |
| 22 | + def test_commit(self): |
| 23 | + r = self.todor |
| 24 | + commit = r.commit('04d55444a3ec06ca8d2aa0a5e333cdaf27113254') |
| 25 | + expect(commit).isinstance(Commit) |
| 26 | + self.assertAreNotNone(commit, 'author', 'committer', 'tree', |
| 27 | + 'message', 'parents', 'sha') |
| 28 | + |
| 29 | + def test_tag(self): |
| 30 | + r = self.todor |
| 31 | + tag = r.tag('6a53c72920c15e196d9a91302bdee2acbe6b44c') |
| 32 | + expect(tag).isinstance(Tag) |
| 33 | + self.assertAreNotNone(tag, 'message', 'object', 'tag', 'tagger', |
| 34 | + 'sha') |
| 35 | + |
| 36 | + def test_tree_and_hash(self): |
| 37 | + r = self.todor |
| 38 | + tree = r.tree('31e862095dffa60744f1ce16a431ea040381f053') |
| 39 | + expect(tree).isinstance(Tree) |
| 40 | + self.assertAreNotNone(tree, 'sha', 'message', 'object', 'tag', |
| 41 | + 'tagger') |
| 42 | + expect(tree.object).isinstance(GitObject) |
| 43 | + hashes = tree.tree # Odd access, right? |
| 44 | + for h in hashes: |
| 45 | + expect(h).isinstance(Hash) |
| 46 | + |
| 47 | + def test_refs(self): |
| 48 | + r = self.todor |
| 49 | + ref = r.ref('heads/development') |
| 50 | + expect(ref).isinstance(Reference) |
0 commit comments