diff --git a/github/Notification.py b/github/Notification.py index 42e15231..20b4a398 100644 --- a/github/Notification.py +++ b/github/Notification.py @@ -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"] diff --git a/github/tests/AuthenticatedUser.py b/github/tests/AuthenticatedUser.py index 77bcae4d..42ef98fe 100644 --- a/github/tests/AuthenticatedUser.py +++ b/github/tests/AuthenticatedUser.py @@ -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, []) diff --git a/github/tests/ReplayData/AuthenticatedUser.testGetNotificationsWithOtherArguments.txt b/github/tests/ReplayData/AuthenticatedUser.testGetNotificationsWithOtherArguments.txt new file mode 100644 index 00000000..88a78000 --- /dev/null +++ b/github/tests/ReplayData/AuthenticatedUser.testGetNotificationsWithOtherArguments.txt @@ -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')] +[] +