From e614a30e129b8b7a54173571a379ffe976696578 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Tue, 8 May 2012 09:13:40 +0100 Subject: [PATCH] Fix testRepositoryCompare --- .../GithubObject.MethodBody.UseResult.py | 4 +++ IntegrationTest.py | 7 ++--- .../description.000.human_readable.json | 12 ++++++- .../description.001.normalized.json | 31 +++++++++++++++++++ github/GithubObjects/Repository.py | 8 ++++- 5 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CodeGenerator/templates/GithubObject.MethodBody.UseResult.py b/CodeGenerator/templates/GithubObject.MethodBody.UseResult.py index ab990b26..f422ec12 100644 --- a/CodeGenerator/templates/GithubObject.MethodBody.UseResult.py +++ b/CodeGenerator/templates/GithubObject.MethodBody.UseResult.py @@ -6,6 +6,10 @@ {% if method.type.cardinality == "scalar" %} +{% if method.type.name == "@todo" %} + return data +{% endif %} + {% if method.type.name == "bool" %} return status == 204 {% endif %} diff --git a/IntegrationTest.py b/IntegrationTest.py index e1c6b2ee..4e7a28ae 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -566,10 +566,9 @@ class IntegrationTest: # p2.edit( state = "closed" ) # self.printList( "Pull requests", r.get_pulls(), lambda p: p.title ) - # @todo Repository.compare - # def testRepositoryCompare( self ): - # r = self.g.get_user().get_repo( "PyGithub" ) - # print str( r.compare( "master", "develop" ) )[ :100 ] + def testRepositoryCompare( self ): + r = self.g.get_user().get_repo( "PyGithub" ) + print str( r.compare( "master", "develop" ) )[ :100 ] # @todo Repository.get_languages # def testRepositoryDetails( self ): diff --git a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index c42ffa93..65d2ef81 100644 --- a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -1543,7 +1543,17 @@ "mandatoryParameters": [ { "name": "base", "type": "@todo" }, { "name": "head", "type": "@todo" } - ] + ], + "request": { + "verb": "GET", + "url": [ + { "type": "attribute", "value": [ "url" ] }, + { "type": "constant", "value": "/compare/" }, + { "type": "argument", "value": [ "base" ] }, + { "type": "constant", "value": "..." }, + { "type": "argument", "value": [ "head" ] } + ] + } } ] }, diff --git a/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/JsonDescriptionOfGithubApiV3/description.001.normalized.json index b842d814..ab1a64f7 100644 --- a/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -9496,6 +9496,37 @@ "name": "head" } ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/compare/" + }, + { + "type": "argument", + "value": [ + "base" + ] + }, + { + "type": "constant", + "value": "..." + }, + { + "type": "argument", + "value": [ + "head" + ] + } + ], + "verb": "GET" + }, "isMutation": false, "optionalParameters": [], "type": { diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 09128c80..50f2aa65 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -197,7 +197,13 @@ class Repository( object ): ) def compare( self, base, head ): - pass + status, headers, data = self.__requester.request( + "GET", + str( self.url ) + "/compare/" + str( base ) + "..." + str( head ), + None, + None + ) + return data def create_download( self, name, size, description = DefaultValueForOptionalParameters, content_type = DefaultValueForOptionalParameters ): post_parameters = {