Skip to content

Commit

Permalink
Merge branch 'feat/test_rework'
Browse files Browse the repository at this point in the history
* feat/test_rework:
  Use mock for sleep in rate limit tests.
  Added BaseData dict setting tests.
  Added BaseData dict key failure test.
  Added test for requires_auth decorator.
  Http mocking switched to use mock.Mock object.
  Rewrite issue 50 test without using Http mock.
  Mark rate limit test with 'slow' attribute.
  [QA] PEP 257 fixes to tests.
  Use nose.tools.ok_ instead of assert_true.
  Use nose.tools.eq_ instead of assert_equals.
  • Loading branch information
JNRowe committed May 16, 2012
2 parents 32a0769 + 5c60b01 commit 63d0a7c
Show file tree
Hide file tree
Showing 15 changed files with 573 additions and 602 deletions.
1 change: 1 addition & 0 deletions extra/requirements-test.txt
@@ -1,3 +1,4 @@
-r requirements.txt
coverage>=3.5
mock>=0.7.1
nose>=1.1.2
6 changes: 3 additions & 3 deletions tests/test_charset_header.py
Expand Up @@ -3,16 +3,16 @@
# This file is part of python-github2, and is made available under the 3-clause
# BSD license. See LICENSE for the full details.

from nose.tools import assert_equals
from nose.tools import eq_

from github2.request import charset_from_headers


def no_match_test():
d = {}
assert_equals("ascii", charset_from_headers(d))
eq_("ascii", charset_from_headers(d))


def utf_test():
d = {'content-type': 'application/json; charset=utf-8'}
assert_equals("utf-8", charset_from_headers(d))
eq_("utf-8", charset_from_headers(d))
67 changes: 31 additions & 36 deletions tests/test_commits.py
Expand Up @@ -5,72 +5,67 @@

from datetime import datetime

from nose.tools import assert_equals
from nose.tools import eq_

import utils


class CommitProperties(utils.HttpMockTestCase):
"""Test commit property handling"""

"""Test commit property handling."""

commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45'

def test_commit(self):
commit = self.client.commits.show('ask/python-github2', self.commit_id)
assert_equals(commit.message,
'Added cache support to manage_collaborators.')
assert_equals(commit.parents,
[{"id": '7d1c855d2f44a55e4b90b40017be697cf70cb4a0'}])
assert_equals(commit.url,
'/ask/python-github2/commit/%s' % self.commit_id)
assert_equals(commit.author['login'], 'JNRowe')
assert_equals(commit.id, self.commit_id)
assert_equals(commit.committed_date,
datetime(2011, 6, 6, 16, 13, 50))
assert_equals(commit.authored_date, datetime(2011, 6, 6, 16, 13, 50))
assert_equals(commit.tree, 'f48fcc1a0b8ea97f3147dc42cf7cdb6683493e94')
assert_equals(commit.committer['login'], 'JNRowe')
assert_equals(commit.added, None)
assert_equals(commit.removed, None)
assert_equals(commit.modified[0]['filename'],
'github2/bin/manage_collaborators.py')
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)
assert_equals(repr(commit),
'<Commit: %s Added cache suppo...>' % self.commit_id[:8])
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')
assert_equals(len(commits), 35)
assert_equals(commits[0].id,
'4de0834d58b37ef3020c49df43c95649217a2def')
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)
assert_equals(len(commits), 35)
assert_equals(commits[0].id,
'1f5ad2c3206bafc4aca9e6ce50f5c605befdb3d6')
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')
assert_equals(len(commits), 35)
assert_equals(commits[0].id,
'025148bdaa6fb6bdac9c3522d481fadf1c0a456f')
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')
assert_equals(len(commits), 35)
assert_equals(commits[0].id,
'fc12b924d34dc38c8ce76d27a866221faa88cb72')
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')
assert_equals(len(commits), 35)
assert_equals(commits[0].id,
'025148bdaa6fb6bdac9c3522d481fadf1c0a456f')
eq_(len(commits), 35)
eq_(commits[0].id, '025148bdaa6fb6bdac9c3522d481fadf1c0a456f')

0 comments on commit 63d0a7c

Please sign in to comment.