From beaa58ca0c038469b3b553b804b4d37b2363f8e2 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 20 May 2012 13:08:17 +0100 Subject: [PATCH] Test IssueEvent attributes --- .../description.000.human_readable.json | 12 ++++++------ .../description.001.normalized.json | 14 +++++++------- doc/ReferenceOfClasses.md | 12 ++++++------ src/github/IssueEvent.py | 9 ++++++++- test/MilestonesAndIssues.py | 10 ++++++++++ test/ReplayData/Issue.testEvents.txt | 15 +++++++++++++++ 6 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 test/ReplayData/Issue.testEvents.txt diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index af92ae43..4714f4a5 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -779,12 +779,12 @@ "name": "IssueEvent", "isCompletable": true, "attributes": [ - { "name": "commit_id", "type": "@todo" }, - { "name": "created_at", "type": "@todo" }, - { "name": "event", "type": "@todo" }, - { "name": "id", "type": "@todo" }, - { "name": "issue", "type": "@todo" }, - { "name": "url", "type": "@todo" }, + { "name": "commit_id", "type": "string" }, + { "name": "created_at", "type": "string" }, + { "name": "event", "type": "string" }, + { "name": "id", "type": "integer" }, + { "name": "issue", "type": "Issue" }, + { "name": "url", "type": "string" }, { "name": "actor", "type": "NamedUser" } ], "collections": [ diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json index 36ec3a25..f290fe01 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -4337,7 +4337,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "commit_id" }, @@ -4345,7 +4345,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "created_at" }, @@ -4353,7 +4353,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "event" }, @@ -4361,15 +4361,15 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "id" }, { "type": { - "simple": true, + "simple": false, "cardinality": "scalar", - "name": "@todo" + "name": "Issue" }, "name": "issue" }, @@ -4377,7 +4377,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" } diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index 8548a55e..526682eb 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -595,12 +595,12 @@ Class `IssueEvent` Attributes ---------- * `actor`: `NamedUser` -* `commit_id` -* `created_at` -* `event` -* `id` -* `issue` -* `url` +* `commit_id`: string +* `created_at`: string +* `event`: string +* `id`: integer +* `issue`: `Issue` +* `url`: string Class `Label` ============= diff --git a/src/github/IssueEvent.py b/src/github/IssueEvent.py index c1bad936..dd541744 100644 --- a/src/github/IssueEvent.py +++ b/src/github/IssueEvent.py @@ -3,6 +3,7 @@ import PaginatedList from GithubObject import * +import Issue import NamedUser class IssueEvent( object ): @@ -81,14 +82,20 @@ class IssueEvent( object ): assert isinstance( attributes[ "actor" ], dict ) self.__actor = NamedUser.NamedUser( self.__requester, attributes[ "actor" ], completion = LazyCompletion ) if "commit_id" in attributes and attributes[ "commit_id" ] is not None: + assert isinstance( attributes[ "commit_id" ], ( str, unicode ) ) self.__commit_id = attributes[ "commit_id" ] if "created_at" in attributes and attributes[ "created_at" ] is not None: + assert isinstance( attributes[ "created_at" ], ( str, unicode ) ) self.__created_at = attributes[ "created_at" ] if "event" in attributes and attributes[ "event" ] is not None: + assert isinstance( attributes[ "event" ], ( str, unicode ) ) self.__event = attributes[ "event" ] if "id" in attributes and attributes[ "id" ] is not None: + assert isinstance( attributes[ "id" ], int ) self.__id = attributes[ "id" ] if "issue" in attributes and attributes[ "issue" ] is not None: - self.__issue = attributes[ "issue" ] + assert isinstance( attributes[ "issue" ], dict ) + self.__issue = Issue.Issue( self.__requester, attributes[ "issue" ], completion = LazyCompletion ) if "url" in attributes and attributes[ "url" ] is not None: + assert isinstance( attributes[ "url" ], ( str, unicode ) ) self.__url = attributes[ "url" ] diff --git a/test/MilestonesAndIssues.py b/test/MilestonesAndIssues.py index b6899c34..e160c44e 100644 --- a/test/MilestonesAndIssues.py +++ b/test/MilestonesAndIssues.py @@ -107,6 +107,16 @@ class Issue( Framework.TestCaseWithRepo ): comment = self.repo.get_issue( 28 ).get_comment( 5808311 ) comment.delete() + def testEvents( self ): + event = self.repo.get_issue( 28 ).get_events()[ 0 ] + self.assertEqual( event.actor.login, "jacquev6" ) + self.assertEqual( event.commit_id, None ) + self.assertEqual( event.created_at, "2012-05-19T10:38:23Z" ) + self.assertEqual( event.event, "subscribed" ) + self.assertEqual( event.id, 15819975 ) + self.assertEqual( event.issue.number, 28 ) + self.assertEqual( event.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/events/15819975" ) + class Label( Framework.TestCaseWithRepo ): def testAttributes( self ): label = self.repo.get_label( "Bug" ) diff --git a/test/ReplayData/Issue.testEvents.txt b/test/ReplayData/Issue.testEvents.txt new file mode 100644 index 00000000..5f62f882 --- /dev/null +++ b/test/ReplayData/Issue.testEvents.txt @@ -0,0 +1,15 @@ +GET /repos/jacquev6/PyGithub/issues/28 {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4968'), ('content-length', '2270'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"988b0ac56d6c092dcd7bc9d9598e60c1"'), ('date', 'Sun, 20 May 2012 12:02:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"closed_by":null,"state":"open","user":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"title":"Title edited by PyGithub","comments":0,"updated_at":"2012-05-20T11:57:12Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"closed_at":null,"body":"Body edited by PyGithub","number":28,"milestone":{"due_on":null,"state":"open","creator":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","title":"Version 1.0: coherent public interface","open_issues":11,"number":2,"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","closed_issues":1,"id":93547,"created_at":"2012-03-08T12:22:28Z"},"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/28","assignee":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"labels":[{"color":"e10c02","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug"},{"color":"444444","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management"},{"color":"02e10c","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question"}],"id":4653757,"html_url":"https://github.com/jacquev6/PyGithub/issues/28","created_at":"2012-05-19T10:38:23Z"} + +GET /repos/jacquev6/PyGithub/issues/28/events {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4967'), ('content-length', '945'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c22776de31a71795b5374ee3c61f51bd"'), ('date', 'Sun, 20 May 2012 12:02:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/events/15819975","commit_id":null,"created_at":"2012-05-19T10:38:23Z","event":"subscribed","id":15819975,"actor":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146}},{"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/events/15820048","commit_id":null,"created_at":"2012-05-19T10:42:25Z","event":"assigned","id":15820048,"actor":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146}}] + +GET /repos/jacquev6/PyGithub/issues/events/15819975 {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '2734'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"a9cee253a596ccc2bbc8c12d425dff08"'), ('date', 'Sun, 20 May 2012 12:02:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"commit_id":null,"event":"subscribed","actor":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/events/15819975","issue":{"state":"open","user":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"title":"Title edited by PyGithub","comments":0,"updated_at":"2012-05-20T11:57:12Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"closed_at":null,"body":"Body edited by PyGithub","number":28,"milestone":{"due_on":null,"state":"open","creator":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","title":"Version 1.0: coherent public interface","open_issues":11,"number":2,"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","closed_issues":1,"id":93547,"created_at":"2012-03-08T12:22:28Z"},"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/28","assignee":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"labels":[{"color":"e10c02","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug"},{"color":"444444","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management"},{"color":"02e10c","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question"}],"id":4653757,"html_url":"https://github.com/jacquev6/PyGithub/issues/28","created_at":"2012-05-19T10:38:23Z"},"id":15819975,"created_at":"2012-05-19T10:38:23Z"} +