Improve test coverage (pull #148)

This commit is contained in:
Vincent Jacques
2013-03-19 22:07:42 +01:00
parent edcf40bc7f
commit 0901df1a2b
3 changed files with 20 additions and 8 deletions
+7 -7
View File
@@ -90,24 +90,24 @@ class Notification(github.GithubObject.GithubObject):
self._url = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "id" in attributes:
if "id" in attributes: # pragma no branch
assert attributes["id"] is None or isinstance(attributes["id"], (str, unicode)), attributes["id"]
self._id = attributes["id"]
if "repository" in attributes:
if "repository" in attributes: # pragma no branch
assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"]
self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, attributes["repository"], completed=False)
if "subject" in attributes:
if "subject" in attributes: # pragma no branch
assert attributes["subject"] is None or isinstance(attributes["subject"], dict), attributes["subject"]
self._subject = None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, attributes["subject"], completed=False)
if "reason" in attributes:
if "reason" in attributes: # pragma no branch
assert attributes["reason"] is None or isinstance(attributes["reason"], (str, unicode)), attributes["reason"]
self._reason = attributes["reason"]
if "unread" in attributes:
if "unread" in attributes: # pragma no branch
assert attributes["unread"] is None or isinstance(attributes["unread"], bool), attributes["unread"]
self._unread = attributes["unread"]
if "updated_at" in attributes:
if "updated_at" in attributes: # pragma no branch
assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str, unicode)), attributes["updated_at"]
self._updated_at = self._parseDatetime(attributes["updated_at"]);
if "url" in attributes:
if "url" in attributes: # pragma no branch
assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"]
self._url = attributes["url"]
+8 -1
View File
@@ -194,6 +194,13 @@ class AuthenticatedUser(Framework.TestCase):
self.assertEqual(notification.subject.title, "Feature/coveralls")
self.assertEqual(notification.subject.type, "PullRequest")
self.assertEqual(notification.repository.id, 8432784)
self.assertEqual(notification.updated_at, datetime.datetime(2013, 3, 15, 5, 43, 11))
self.assertEqual(notification.url, None)
self.assertEqual(notification.subject.url, None)
self.assertEqual(notification.subject.latest_comment_url, None)
def testGetNotifications(self):
self.assertListKeyBegin(self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"])
self.assertListKeyEqual(self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"])
def testGetNotificationsWithOtherArguments(self):
self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, [])
@@ -0,0 +1,5 @@
https GET api.github.com None /notifications?all=True {'Authorization': 'Basic login_and_password_removed'} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('content-length', '2'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d751713988987e9331980363e24189ce"'), ('cache-control', 'max-age=0, private, must-revalidate'), ('date', 'Tue, 19 Mar 2013 21:05:52 GMT'), ('content-type', 'application/json; charset=utf-8')]
[]