From ae81345d06311446375c8c614fa23a7e20e52f56 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sat, 3 Mar 2012 11:10:12 +0000 Subject: [PATCH] testIssuesAndMilestones --- NewIntegrationTest.py | 56 +++++++++++++++++++++++++++++++++ github/GithubObject.UnitTest.py | 4 +++ github/GithubObjects.py | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/NewIntegrationTest.py b/NewIntegrationTest.py index 3f803db0..1070a038 100644 --- a/NewIntegrationTest.py +++ b/NewIntegrationTest.py @@ -281,6 +281,62 @@ class IntegrationTest: r.create_git_ref( "refs/tags/tagCreatedByPyGithub", tag.sha ) reTag = r.get_git_tag( tag.sha ) + def testIssuesAndMilestones( self ): + u = self.g.get_user() + r = u.get_repo( "TestPyGithub" ) + + self.printList( "Issues", r.get_issues(), lambda i: i.title ) + i = r.create_issue( "Issue created by PyGithub" ) + self.printList( "Issues", r.get_issues(), lambda i: i.title ) + i.edit( body = "Issue edited by PyGithub" ) + + self.printList( "Comments on issue", i.get_comments(), lambda c: c.body ) + c = i.create_comment( "Comment created by PyGithub" ) + self.printList( "Comments on issue", i.get_comments(), lambda c: c.body ) + c.edit( "Comment edited by PyGithub" ) + sameComment = i.get_comment( c.id ) + self.printList( "Comments on issue", i.get_comments(), lambda c: c.body ) + c.delete() + self.printList( "Comments on issue", i.get_comments(), lambda c: c.body ) + + self.printList( "Milestones", r.get_milestones(), lambda m: m.title ) + m = r.create_milestone( "Milestone created by PyGithub" ) + self.printList( "Milestones", r.get_milestones(), lambda m: m.title ) + m.edit( title = "Milestone edited by PyGithub" ) + self.printList( "Milestones", r.get_milestones(), lambda m: m.title ) + + self.printList( "Issues of milestone", r.get_issues( milestone = m.number ), lambda i: i.title ) + i.edit( milestone = m.number ) + self.printList( "Issues of milestone", r.get_issues( milestone = m.number ), lambda i: i.title ) + + self.printList( "Repository labels", r.get_labels(), lambda l: l.name ) + labelD = r.create_label( "D", "FF0000" ) + self.printList( "Repository labels", r.get_labels(), lambda l: l.name ) + ### @todo Uncomment after fixing bug about BaseUrl depending on editable attribute + # labelD.edit( "Dada", "00FF00" ) + # self.printList( "Repository labels", r.get_labels(), lambda l: l.name ) + labelD.delete() + self.printList( "Repository labels", r.get_labels(), lambda l: l.name ) + + labelA = r.get_label( "bug" ) + labelB = r.get_label( "duplicate" ) + labelC = r.get_label( "invalid" ) + + self.printList( "Labels", i.get_labels(), lambda l: l.name ) + i.set_labels( labelA, labelB ) + self.printList( "Labels", i.get_labels(), lambda l: l.name ) + i.remove_from_labels( labelB ) + self.printList( "Labels", i.get_labels(), lambda l: l.name ) + i.delete_labels() + self.printList( "Labels", i.get_labels(), lambda l: l.name ) + i.add_to_labels( labelB, labelC ) + self.printList( "Labels", i.get_labels(), lambda l: l.name ) + + self.printList( "Milestone labels", r.get_milestone( m.number ).get_labels(), lambda l: l.name ) + + m.delete() + self.printList( "Milestones", r.get_milestones(), lambda m: m.title ) + def testKeys( self ): u = self.g.get_user() self.printList( "Keys", u.get_keys(), lambda k: k.title ) diff --git a/github/GithubObject.UnitTest.py b/github/GithubObject.UnitTest.py index d4f90921..e1848b89 100644 --- a/github/GithubObject.UnitTest.py +++ b/github/GithubObject.UnitTest.py @@ -3,6 +3,10 @@ import MockMockMock from GithubObject import * +### @todo add a test where BaseUrl depends on some editable attribute. +### Show that BaseUrl is faithfull to the edited attribute +### (currently not the case for Label, whish has a BaseUrl depending on its name) + class GithubObjectTestCase( unittest.TestCase ): def testDuplicatedAttributeInOnePolicy( self ): with self.assertRaises( BadGithubObjectException ): diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 2eac6927..10332435 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -220,7 +220,7 @@ Milestone = GithubObject( IssueComment = GithubObject( "IssueComment", - BaseUrl( lambda obj: obj._repo._baseUrl + "/issues/comment" + str( obj.id ) ), + BaseUrl( lambda obj: obj._repo._baseUrl + "/issues/comments/" + str( obj.id ) ), InternalSimpleAttributes( "url", "body", "created_at", "updated_at", "id", "_repo", ### Ugly hack