forked from ask/python-github2
/
test_commits.py
71 lines (54 loc) · 2.66 KB
/
test_commits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright (C) 2011-2012 James Rowe <jnrowe@gmail.com>
#
# This file is part of python-github2, and is made available under the 3-clause
# BSD license. See LICENSE for the full details.
from datetime import datetime
from nose.tools import eq_
import utils
class CommitProperties(utils.HttpMockTestCase):
"""Test commit property handling."""
commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45'
def test_commit(self):
commit = self.client.commits.show('ask/python-github2', self.commit_id)
eq_(commit.message, 'Added cache support to manage_collaborators.')
eq_(commit.parents,
[{"id": '7d1c855d2f44a55e4b90b40017be697cf70cb4a0'}])
eq_(commit.url, '/ask/python-github2/commit/%s' % self.commit_id)
eq_(commit.author['login'], 'JNRowe')
eq_(commit.id, self.commit_id)
eq_(commit.committed_date, datetime(2011, 6, 6, 16, 13, 50))
eq_(commit.authored_date, datetime(2011, 6, 6, 16, 13, 50))
eq_(commit.tree, 'f48fcc1a0b8ea97f3147dc42cf7cdb6683493e94')
eq_(commit.committer['login'], 'JNRowe')
eq_(commit.added, None)
eq_(commit.removed, None)
eq_(commit.modified[0]['filename'],
'github2/bin/manage_collaborators.py')
def test_repr(self):
commit = self.client.commits.show('ask/python-github2', self.commit_id)
eq_(repr(commit),
'<Commit: %s Added cache suppo...>' % self.commit_id[:8])
class CommitsQueries(utils.HttpMockTestCase):
"""Test commit querying"""
def test_list(self):
commits = self.client.commits.list('JNRowe/misc-overlay')
eq_(len(commits), 35)
eq_(commits[0].id, '4de0834d58b37ef3020c49df43c95649217a2def')
def test_list_with_page(self):
commits = self.client.commits.list('JNRowe/jnrowe-misc', page=2)
eq_(len(commits), 35)
eq_(commits[0].id, '1f5ad2c3206bafc4aca9e6ce50f5c605befdb3d6')
def test_list_with_branch(self):
commits = self.client.commits.list('JNRowe/misc-overlay', 'gh-pages')
eq_(len(commits), 35)
eq_(commits[0].id, '025148bdaa6fb6bdac9c3522d481fadf1c0a456f')
def test_list_with_file(self):
commits = self.client.commits.list('JNRowe/misc-overlay',
file='Makefile')
eq_(len(commits), 35)
eq_(commits[0].id, 'fc12b924d34dc38c8ce76d27a866221faa88cb72')
def test_list_with_branch_and_file(self):
commits = self.client.commits.list('JNRowe/misc-overlay', 'gh-pages',
'packages/dev-python.html')
eq_(len(commits), 35)
eq_(commits[0].id, '025148bdaa6fb6bdac9c3522d481fadf1c0a456f')