Skip to content

Commit ef3d3a1

Browse files
committed
Merge branch 'feat/object_properties_coverage'
* feat/object_properties_coverage: Added pull request properties tests. Added organisation properties tests. Added issue/comment properties tests. Added commit properties tests. Conflicts: tests/test_commits.py tests/test_issues.py tests/test_organizations.py tests/test_pull_requests.py
2 parents 5a6ff55 + 79d4d03 commit ef3d3a1

4 files changed

Lines changed: 120 additions & 5 deletions

File tree

tests/test_commits.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
from datetime import datetime
2+
13
from nose.tools import assert_equals
24

35
import utils
46

57

6-
class Commit(utils.HttpMockTestCase):
8+
class CommitProperties(utils.HttpMockTestCase):
9+
"""Test commit property handling"""
10+
commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45'
11+
def test_commit(self):
12+
commit = self.client.commits.show('ask/python-github2', self.commit_id)
13+
assert_equals(commit.message,
14+
'Added cache support to manage_collaborators.')
15+
assert_equals(commit.parents,
16+
[{"id": '7d1c855d2f44a55e4b90b40017be697cf70cb4a0'}])
17+
assert_equals(commit.url,
18+
'/ask/python-github2/commit/%s' % self.commit_id)
19+
assert_equals(commit.author['login'], 'JNRowe')
20+
assert_equals(commit.id, self.commit_id)
21+
assert_equals(commit.committed_date,
22+
datetime(2011, 6, 6, 16, 13, 50))
23+
assert_equals(commit.authored_date, datetime(2011, 6, 6, 16, 13, 50))
24+
assert_equals(commit.tree, 'f48fcc1a0b8ea97f3147dc42cf7cdb6683493e94')
25+
assert_equals(commit.committer['login'], 'JNRowe')
26+
assert_equals(commit.added, None)
27+
assert_equals(commit.removed, None)
28+
assert_equals(commit.modified[0]['filename'], 'github2/bin/manage_collaborators.py')
29+
30+
731
def test_repr(self):
8-
commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45'
9-
commit = self.client.commits.show('ask/python-github2', commit_id)
32+
commit = self.client.commits.show('ask/python-github2', self.commit_id)
1033
assert_equals(repr(commit),
11-
'<Commit: %s Added cache suppo...>' % commit_id[:8])
34+
'<Commit: %s Added cache suppo...>' % self.commit_id[:8])
1235

1336

1437
class CommitsQueries(utils.HttpMockTestCase):

tests/test_issues.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
1+
from datetime import datetime
2+
13
from nose.tools import assert_equals
24

35
import utils
46

57

6-
class ReprTests(utils.HttpMockTestCase):
8+
class Issue(utils.HttpMockTestCase):
9+
def test_properties(self):
10+
issue = self.client.issues.show('ask/python-github2', 24)
11+
assert_equals(issue.position, 24.0)
12+
assert_equals(issue.number, 24)
13+
assert_equals(issue.votes, 0)
14+
assert_equals(len(issue.body), 164)
15+
assert_equals(issue.title, 'Pagination support for commits.')
16+
assert_equals(issue.user, 'svetlyak40wt')
17+
assert_equals(issue.state, 'open')
18+
assert_equals(issue.labels, [])
19+
assert_equals(issue.created_at, datetime(2010, 12, 8, 23, 50, 26))
20+
assert_equals(issue.closed_at, None)
21+
assert_equals(issue.updated_at, datetime(2011, 1, 4, 16, 26, 7))
22+
assert_equals(issue.diff_url,
23+
'https://github.com/ask/python-github2/pull/24.diff')
24+
assert_equals(issue.patch_url,
25+
'https://github.com/ask/python-github2/pull/24.patch')
26+
assert_equals(issue.pull_request_url,
27+
'https://github.com/ask/python-github2/pull/24')
28+
729
def test_issue_repr(self):
830
issue = self.client.issues.show('ask/python-github2', 24)
931
assert_equals(repr(issue),
1032
'<Issue: Pagination suppor...>')
1133

34+
35+
class Comment(utils.HttpMockTestCase):
36+
def test_properties(self):
37+
comments = self.client.issues.comments('ask/python-github2', 24)
38+
comment = comments[0]
39+
assert_equals(comment.created_at, datetime(2010, 12, 9, 22, 37, 26))
40+
assert_equals(comment.updated_at, datetime(2010, 12, 9, 22, 37, 26))
41+
assert_equals(len(comment.body), 267)
42+
assert_equals(comment.id, 601871)
43+
assert_equals(comment.user, 'nvie')
44+
1245
def test_comment_repr(self):
1346
comments = self.client.issues.comments('ask/python-github2', 24)
1447
assert_equals(repr(comments[1]),

tests/test_organizations.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
1+
from datetime import datetime
2+
13
from nose.tools import (assert_equals, assert_true)
24

35
import utils
46

57

68
class OrganizationProperties(utils.HttpMockTestCase):
9+
def test_properties(self):
10+
organization = self.client.organizations.show('github')
11+
assert_equals(organization.id, 9919)
12+
assert_equals(organization.name, 'GitHub')
13+
assert_equals(organization.blog, 'https://github.com/about')
14+
assert_equals(organization.location, 'San Francisco, CA')
15+
assert_equals(organization.gravatar_id,
16+
'61024896f291303615bcd4f7a0dcfb74')
17+
assert_equals(organization.login, 'github')
18+
assert_equals(organization.email, 'support@github.com')
19+
assert_equals(organization.company, None)
20+
assert_equals(organization.created_at,
21+
datetime(2008, 5, 10, 21, 37, 31))
22+
assert_equals(organization.following_count, 0)
23+
assert_equals(organization.followers_count, 591)
24+
assert_equals(organization.public_gist_count, 0)
25+
assert_equals(organization.public_repo_count, 31)
26+
assert_equals(organization.permission, None)
27+
assert_equals(organization.plan, None)
28+
729
def test_is_authenticated(self):
830
organization = self.client.organizations.show('github')
931
assert_true(organization.is_authenticated() is False)

tests/test_pull_requests.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1+
from datetime import datetime
2+
13
from nose.tools import assert_equals
24

35
import utils
46

57

68
class PullRequest(utils.HttpMockTestCase):
9+
def test_properties(self):
10+
pull_request = self.client.pull_requests.show('ask/python-github2', 39)
11+
assert_equals(pull_request.state, 'closed')
12+
assert_equals(pull_request.base['sha'],
13+
'0786a96c80afad7bbd0747df590f649eaa46ca04')
14+
assert_equals(pull_request.head['sha'],
15+
'5438e41d9c390f53089ed3fa0842831fafc73d8e')
16+
assert_equals(pull_request.issue_user['login'], 'JNRowe')
17+
assert_equals(pull_request.user['login'], 'JNRowe')
18+
assert_equals(pull_request.title, 'Datetime timezone handling.')
19+
assert_equals(len(pull_request.body), 1442)
20+
assert_equals(pull_request.position, 39.0)
21+
assert_equals(pull_request.number, 39.0)
22+
assert_equals(pull_request.votes, 0)
23+
assert_equals(pull_request.comments, 4)
24+
assert_equals(pull_request.diff_url,
25+
'https://github.com/ask/python-github2/pull/39.diff')
26+
assert_equals(pull_request.patch_url,
27+
'https://github.com/ask/python-github2/pull/39.patch')
28+
assert_equals(pull_request.labels, [])
29+
assert_equals(pull_request.html_url,
30+
'https://github.com/ask/python-github2/pull/39')
31+
assert_equals(pull_request.issue_created_at,
32+
datetime(2011, 4, 18, 15, 25, 47))
33+
assert_equals(pull_request.issue_updated_at,
34+
datetime(2011, 6, 23, 9, 33, 57))
35+
assert_equals(pull_request.created_at,
36+
datetime(2011, 6, 20, 16, 51, 24))
37+
assert_equals(pull_request.updated_at,
38+
datetime(2011, 6, 23, 9, 28, 42))
39+
assert_equals(pull_request.closed_at,
40+
datetime(2011, 6, 23, 9, 33, 57))
41+
assert_equals(len(pull_request.discussion), 13)
42+
assert_equals(pull_request.mergeable, True)
43+
744
def test_repr(self):
845
pull_request = self.client.pull_requests.show('ask/python-github2', 39)
946
assert_equals(repr(pull_request),

0 commit comments

Comments
 (0)