From d6835ff949141957a733c8ddfa147026515ae493 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Mon, 28 May 2012 18:29:08 +0200 Subject: [PATCH] dos2unix --- codegen/GenerateCode.py | 120 +-- .../JsonDescriptionOfGithubApiV3/normalize.py | 752 +++++++++--------- .../GithubObject.MethodBody.DoRequest.py | 244 +++--- .../GithubObject.MethodBody.UseResult.py | 76 +- test/Authorization.py | 70 +- test/Download.py | 62 +- test/Event.py | 32 +- test/Framework.py | 292 +++---- test/Gist.py | 132 +-- test/GistComment.py | 44 +- test/Github.py | 10 +- test/Issue.py | 146 ++-- test/IssueComment.py | 44 +- test/IssueEvent.py | 30 +- test/Label.py | 40 +- test/Milestone.py | 72 +- test/PullRequest.py | 132 +-- test/PullRequestComment.py | 52 +- test/PullRequestFile.py | 34 +- test/ReplayData/CommitComment.setUp.txt | 30 +- test/ReplayData/GistComment.setUp.txt | 20 +- test/ReplayData/IssueComment.setUp.txt | 40 +- test/ReplayData/Milestone.setUp.txt | 30 +- .../ReplayData/NamedUser.testGetFollowers.txt | 10 +- test/ReplayData/Organization.setUp.txt | 10 +- .../Organization.testEditWithoutArguments.txt | 10 +- .../RateLimiting.testRateLimiting.txt | 10 +- .../Repository.testCreateGitBlob.txt | 10 +- test/RepositoryKey.py | 48 +- test/Team.py | 98 +-- test/UserKey.py | 48 +- 31 files changed, 1374 insertions(+), 1374 deletions(-) diff --git a/codegen/GenerateCode.py b/codegen/GenerateCode.py index e2da2683..d4cb122d 100644 --- a/codegen/GenerateCode.py +++ b/codegen/GenerateCode.py @@ -1,60 +1,60 @@ -#!/bin/env python - -import os -import json -import itertools - -import django.conf -import django.template -import django.template.loader - -django.conf.settings.configure( - TEMPLATE_DIRS = ( - os.path.join( os.path.dirname( __file__ ), "templates" ), - ), - TEMPLATE_STRING_IF_INVALID = "We have a logic error in our template or API description", -) - -description = json.load( open( os.path.join( os.path.dirname( __file__ ), "JsonDescriptionOfGithubApiV3", "description.001.normalized.json" ) ) ) - -for class_ in description[ "classes" ]: - dependencies = set() - for thing in itertools.chain( class_[ "methods" ], class_[ "attributes" ] ): - if not thing[ "type" ][ "simple" ]: - dependencies.add( thing[ "type" ][ "name" ] ) - class_[ "dependencies" ] = list( dependencies ) - class_[ "needsUrllib" ] = class_[ "name" ] in [ "Label", "Repository" ] - -githubObjectTemplate = django.template.loader.get_template( "GithubObject.py" ) -for class_ in description[ "classes" ]: - with open( os.path.join( os.path.dirname( __file__ ), "..", "src", "github", class_[ "name" ] + ".py" ), "w" ) as f: - f.write( "# WARNING: this file is generated automaticaly.\n" ) - f.write( "# Do not modify it manually, your work would be lost.\n" ) - f.write( "\n" ) - rawCode = githubObjectTemplate.render( django.template.Context( { "class": class_ } ) ).split( "\n" ) - code = list() - for line in rawCode: - line = line.rstrip() - if line == "": - continue - if len( code ) > 0 and code[ -1 ].startswith( " " ) and line.startswith( " " ) and not line.startswith( " " ): - code.append( "" ) - if line.startswith( "class" ): - code.append( "" ) - code.append( line ) - f.write( "\n".join( code ) + "\n" ) - -referenceOfClassesTemplate = django.template.loader.get_template( "ReferenceOfClasses.md" ) -with open( os.path.join( os.path.dirname( __file__ ), "..", "doc", "ReferenceOfClasses.md" ), "w" ) as f: - rawCode = referenceOfClassesTemplate.render( django.template.Context( description ) ).split( "\n" ) - code = list() - for line in rawCode: - line = line.rstrip() - if line == "": - continue - if not line.lstrip().startswith( "*" ) and len( code ) > 0: - prevLine = code[ -1 ].lstrip() - if prevLine.startswith( "*" ) or prevLine.startswith( "=" ): - code.append( "" ) - code.append( line ) - f.write( "\n".join( code ) + "\n" ) +#!/bin/env python + +import os +import json +import itertools + +import django.conf +import django.template +import django.template.loader + +django.conf.settings.configure( + TEMPLATE_DIRS = ( + os.path.join( os.path.dirname( __file__ ), "templates" ), + ), + TEMPLATE_STRING_IF_INVALID = "We have a logic error in our template or API description", +) + +description = json.load( open( os.path.join( os.path.dirname( __file__ ), "JsonDescriptionOfGithubApiV3", "description.001.normalized.json" ) ) ) + +for class_ in description[ "classes" ]: + dependencies = set() + for thing in itertools.chain( class_[ "methods" ], class_[ "attributes" ] ): + if not thing[ "type" ][ "simple" ]: + dependencies.add( thing[ "type" ][ "name" ] ) + class_[ "dependencies" ] = list( dependencies ) + class_[ "needsUrllib" ] = class_[ "name" ] in [ "Label", "Repository" ] + +githubObjectTemplate = django.template.loader.get_template( "GithubObject.py" ) +for class_ in description[ "classes" ]: + with open( os.path.join( os.path.dirname( __file__ ), "..", "src", "github", class_[ "name" ] + ".py" ), "w" ) as f: + f.write( "# WARNING: this file is generated automaticaly.\n" ) + f.write( "# Do not modify it manually, your work would be lost.\n" ) + f.write( "\n" ) + rawCode = githubObjectTemplate.render( django.template.Context( { "class": class_ } ) ).split( "\n" ) + code = list() + for line in rawCode: + line = line.rstrip() + if line == "": + continue + if len( code ) > 0 and code[ -1 ].startswith( " " ) and line.startswith( " " ) and not line.startswith( " " ): + code.append( "" ) + if line.startswith( "class" ): + code.append( "" ) + code.append( line ) + f.write( "\n".join( code ) + "\n" ) + +referenceOfClassesTemplate = django.template.loader.get_template( "ReferenceOfClasses.md" ) +with open( os.path.join( os.path.dirname( __file__ ), "..", "doc", "ReferenceOfClasses.md" ), "w" ) as f: + rawCode = referenceOfClassesTemplate.render( django.template.Context( description ) ).split( "\n" ) + code = list() + for line in rawCode: + line = line.rstrip() + if line == "": + continue + if not line.lstrip().startswith( "*" ) and len( code ) > 0: + prevLine = code[ -1 ].lstrip() + if prevLine.startswith( "*" ) or prevLine.startswith( "=" ): + code.append( "" ) + code.append( line ) + f.write( "\n".join( code ) + "\n" ) diff --git a/codegen/JsonDescriptionOfGithubApiV3/normalize.py b/codegen/JsonDescriptionOfGithubApiV3/normalize.py index 9a253e03..782f5119 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/normalize.py +++ b/codegen/JsonDescriptionOfGithubApiV3/normalize.py @@ -1,376 +1,376 @@ -#!/bin/env python - -import os.path -import json -import itertools - -### @todo Mandatory/optional attributes -### @todo Remove '_identity' from the normalized json description - -def mergeDict( base, *additions ): - r = dict( base ) - for addition in additions: - for k in addition: - if k in r: - if isinstance( r[ k ], dict ): - r[ k ] = mergeDict( r[ k ], addition[ k ] ) - # else: - # we ignore the addition: the first dict which specifies a value wins - else: - r[ k ] = addition[ k ] - return r - -def checkKeys( d, mandatoryKeys, optionalKeys = [] ): - assert set( d.keys() ) >= set( mandatoryKeys ), d.keys() - assert set( d.keys() ) <= set( mandatoryKeys ) | set( optionalKeys ) | set( [ "@todo" ] ), d.keys() - -class Type: - def __init__( self, arg ): - if isinstance( arg, ( str, unicode ) ): - self.__fromString( arg ) - else: - self.__fromDesc( arg ) - - def ToJson( self ): - return { - "cardinality": self.cardinality, - "name": self.name, - "simple": self.name in [ "void", "string", "integer", "bool", "float", "@todo" ], - } - - def __fromString( self, name ): - listPrefix = "list:" - if name.startswith( listPrefix ): - self.cardinality = "list" - self.name = name[ len( listPrefix ) : ] - else: - self.cardinality = "scalar" - self.name = name - - def __fromDesc( self, desc ): - checkKeys( desc, [ "cardinality", "name" ] ) - - self.cardinality = desc[ "cardinality" ] - self.name = desc[ "name" ] - -class Variable: - def __init__( self, desc ): - checkKeys( desc, [ "name", "type" ] ) - - self.name = desc[ "name" ] - self.type = Type( desc[ "type" ] ) - - def ToJson( self ): - return { - "name": self.name, - "type": self.type, - } - -class Function: - # method - # input - # self - # arguments - # output - # type - # bool - # object - # fundamental type - # list of - # object - # fundamental type - # body - # status or data request - # url from input - # GET parameters from input - # POST parameters from input - - def __init__( self, desc, *additionalDescs ): - desc = mergeDict( desc, *additionalDescs ) - checkKeys( desc, [ "name", "type", "group" ], [ "url", "isMutation", "mandatoryParameters", "optionalParameters", "variadicParameter", "parameter", "request" ] ) # @todo Move request to mandatoryKeys - - self.name = desc[ "name" ] - self.type = Type( desc[ "type" ] ) - self.group = desc[ "group" ] - self.isMutation = "isMutation" in desc and desc[ "isMutation" ] - self.mandatoryParameters = list() - if "mandatoryParameters" in desc: - for parameter in desc[ "mandatoryParameters" ]: - self.mandatoryParameters.append( Variable( parameter ) ) - self.optionalParameters = list() - if "optionalParameters" in desc: - for parameter in desc[ "optionalParameters" ]: - self.optionalParameters.append( Variable( parameter ) ) - if "variadicParameter" in desc: - self.variadicParameter = Variable( desc[ "variadicParameter" ] ) - else: - self.variadicParameter = None - if "request" in desc: - self.request = desc[ "request" ] - else: - self.request = None - - def ToJson( self ): - json = { - "name": self.name, - "type": self.type, - "group": self.group, - "isMutation": self.isMutation, - "mandatoryParameters": self.mandatoryParameters, - "optionalParameters": self.optionalParameters, - } - if self.variadicParameter is not None: - json[ "variadicParameter" ] = self.variadicParameter - if self.request is not None: - json[ "request" ] = self.request - return json - -class Collection: - def __init__( self, desc, ownerUrl ): - checkKeys( desc, [ "name", "singularName", "type" ], [ "addElement", "addSeveralElements", "createElement", "deleteList", "getElement", "getList", "hasElement", "removeElement", "removeSeveralElements", "setList", "url" ] ) - - if "url" in desc: - self.__url = desc[ "url" ] - else: - self.__url = ownerUrl + [ - { "type": "constant", "value": "/" + desc[ "name" ] }, - ] - - name = desc[ "name" ] if isinstance( desc[ "name" ], list ) else [ desc[ "name" ] ] - self.methods = list() - if "addElement" in desc: - assert desc[ "addElement" ] is True - self.methods.append( Function( - { "name": [ "add", "to" ] + name, "type": "void", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, - { - "request": { - "verb": "PUT", - "url": self.__url + [ - { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, - ], - "information": "status", - } - } - ) ) - if "addSeveralElements" in desc: - assert desc[ "addSeveralElements" ] is True - self.methods.append( Function( - { "name": [ "add", "to" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, - { - "request": { - "verb": "POST", - "url": self.__url, - "information": "status", - "postParameters": True - } - } - ) ) - if "createElement" in desc: - self.methods.append( Function( - desc[ "createElement" ], - { "name": [ "create", desc[ "singularName" ] ], "type": desc[ "type" ], "group": desc[ "name" ] }, - { - "request": { - "verb": "POST", - "url": self.__url, - "information": "status", - "postParameters": True, - } - } - ) ) - if "deleteList" in desc: - assert desc[ "deleteList" ] is True - self.methods.append( Function( - { "name": [ "delete" ] + name, "type": "void", "group": desc[ "name" ] }, - { - "request": { - "verb": "DELETE", - "url": self.__url, - "information": "status", - } - } - ) ) - if "getElement" in desc: - if "url" in desc[ "getElement" ]: - urlForGetElement = desc[ "getElement" ][ "url" ] - else: - urlForGetElement = self.__url + [ - { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ desc[ "getElement" ][ "parameter" ][ "name" ] ] }, - ] - - self.methods.append( Function( - desc[ "getElement" ], - { "name": [ "get", desc[ "singularName" ] ], "type": desc[ "type" ], "group": desc[ "name" ], "mandatoryParameters": [ desc[ "getElement" ][ "parameter" ] ] }, - { - "request": { - "verb": "GET", - "url": urlForGetElement, - "information": "data", - } - } - ) ) - if "getList" in desc: - self.methods.append( Function( - desc[ "getList" ] if desc[ "getList" ] is not True else dict(), - { "name": [ "get" ] + name, "type": { "cardinality": "list", "name": desc[ "type" ] }, "group": desc[ "name" ] }, - { - "request": { - "verb": "GET", - "url": self.__url, - "information": "data", - } - } - ) ) - if "hasElement" in desc: - assert desc[ "hasElement" ] is True - self.methods.append( Function( - { "name": [ "has", "in" ] + name, "type": "bool", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, - { - "request": { - "verb": "GET", - "url": self.__url + [ - { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, - ], - "information": "status", - } - } - ) ) - if "removeElement" in desc: - assert desc[ "removeElement" ] is True - self.methods.append( Function( - { "name": [ "remove", "from" ] + name, "type": "void", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, - { - "request": { - "verb": "DELETE", - "url": self.__url + [ - { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, - ], - "information": "status", - } - } - ) ) - if "removeSeveralElements" in desc: - assert desc[ "removeSeveralElements" ] is True - self.methods.append( Function( - { "name": [ "remove", "from" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, - { - "request": { - "verb": "DELETE", - "url": self.__url, - "information": "status", - "postParameters": True - } - } - ) ) - if "setList" in desc: - assert desc[ "setList" ] is True - self.methods.append( Function( - { "name": [ "set" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, - { - "request": { - "verb": "PUT", - "url": self.__url, - "information": "status", - "postParameters": True, - } - } - ) ) - -class Class: - def __init__( self, desc ): - checkKeys( desc, [ "name", "attributes" ], [ "isCompletable", "url", "identity", "edit", "delete", "additionalMethods", "collections" ] ) - - self.name = desc[ "name" ] - self.attributes = sorted( - [ - Variable( attr ) - for attr in desc[ "attributes" ] - ], - key = lambda class_: class_.name - ) - self.isCompletable = "isCompletable" in desc and desc[ "isCompletable" ] - self.methods = [] - if "identity" in desc: - self.identity = desc[ "identity" ] - else: - self.identity = None - if "edit" in desc: - self.methods.append( Function( - desc[ "edit" ], - { "name": [ "edit" ], "type": "void", "group": "modification", "isMutation": True }, - { - "request": { - "verb": "PATCH", - "url": [ { "type": "constant", "value": "https://api.github.com/user" } if desc[ "name" ] == "AuthenticatedUser" else { "type": "attribute", "value": [ "url" ] } ], # @todo - "postParameters": True, # @todo - "information": "data", - }, - } - ) ) - if "delete" in desc: - self.methods.append( Function( - { "name": [ "delete" ], "type": "void", "group": "deletion" }, - { - "request": { - "verb": "DELETE", - "url": [ { "type": "attribute", "value": [ "url" ] } ], - "information": "data", - }, - } - ) ) - if "url" in desc: - url = desc[ "url" ] - else: - url = [ { "type": "attribute", "value": [ "url" ] } ] - if "collections" in desc: - for collection in [ Collection( collection, url ) for collection in desc[ "collections" ] ]: - self.methods += collection.methods - if "additionalMethods" in desc: - self.methods += [ Function( method ) for method in desc[ "additionalMethods" ] ] - - def ToJson( self ): - d = { - "name": self.name, - "attributes": self.attributes, - "methods": self.methods, - "isCompletable": self.isCompletable, - } - if self.identity is not None: - d[ "identity" ] = self.identity - return d - -class Description: - def __init__( self, desc ): - checkKeys( desc, [ "classes" ] ) - - self.classes = sorted( - [ - Class( class_ ) - for class_ in desc[ "classes" ] - ], - key = lambda class_: class_.name - ) - - def ToJson( self ): - return { - "classes": self.classes, - } - - def save( self, fileName ): - class Encoder( json.JSONEncoder ): - def default( self, obj ): - if hasattr( obj, "ToJson" ): - return obj.ToJson() - return json.JSONEncoder.default( self, obj ) - - with open( os.path.join( os.path.dirname( __file__ ), fileName ), "w" ) as f: - json.dump( self, f, indent = 4, cls = Encoder ) - -with open( os.path.join( os.path.dirname( __file__ ), "description.000.human_readable.json" ) ) as f: - description = Description( json.load( f ) ) - -description.save( "description.001.normalized.json" ) +#!/bin/env python + +import os.path +import json +import itertools + +### @todo Mandatory/optional attributes +### @todo Remove '_identity' from the normalized json description + +def mergeDict( base, *additions ): + r = dict( base ) + for addition in additions: + for k in addition: + if k in r: + if isinstance( r[ k ], dict ): + r[ k ] = mergeDict( r[ k ], addition[ k ] ) + # else: + # we ignore the addition: the first dict which specifies a value wins + else: + r[ k ] = addition[ k ] + return r + +def checkKeys( d, mandatoryKeys, optionalKeys = [] ): + assert set( d.keys() ) >= set( mandatoryKeys ), d.keys() + assert set( d.keys() ) <= set( mandatoryKeys ) | set( optionalKeys ) | set( [ "@todo" ] ), d.keys() + +class Type: + def __init__( self, arg ): + if isinstance( arg, ( str, unicode ) ): + self.__fromString( arg ) + else: + self.__fromDesc( arg ) + + def ToJson( self ): + return { + "cardinality": self.cardinality, + "name": self.name, + "simple": self.name in [ "void", "string", "integer", "bool", "float", "@todo" ], + } + + def __fromString( self, name ): + listPrefix = "list:" + if name.startswith( listPrefix ): + self.cardinality = "list" + self.name = name[ len( listPrefix ) : ] + else: + self.cardinality = "scalar" + self.name = name + + def __fromDesc( self, desc ): + checkKeys( desc, [ "cardinality", "name" ] ) + + self.cardinality = desc[ "cardinality" ] + self.name = desc[ "name" ] + +class Variable: + def __init__( self, desc ): + checkKeys( desc, [ "name", "type" ] ) + + self.name = desc[ "name" ] + self.type = Type( desc[ "type" ] ) + + def ToJson( self ): + return { + "name": self.name, + "type": self.type, + } + +class Function: + # method + # input + # self + # arguments + # output + # type + # bool + # object + # fundamental type + # list of + # object + # fundamental type + # body + # status or data request + # url from input + # GET parameters from input + # POST parameters from input + + def __init__( self, desc, *additionalDescs ): + desc = mergeDict( desc, *additionalDescs ) + checkKeys( desc, [ "name", "type", "group" ], [ "url", "isMutation", "mandatoryParameters", "optionalParameters", "variadicParameter", "parameter", "request" ] ) # @todo Move request to mandatoryKeys + + self.name = desc[ "name" ] + self.type = Type( desc[ "type" ] ) + self.group = desc[ "group" ] + self.isMutation = "isMutation" in desc and desc[ "isMutation" ] + self.mandatoryParameters = list() + if "mandatoryParameters" in desc: + for parameter in desc[ "mandatoryParameters" ]: + self.mandatoryParameters.append( Variable( parameter ) ) + self.optionalParameters = list() + if "optionalParameters" in desc: + for parameter in desc[ "optionalParameters" ]: + self.optionalParameters.append( Variable( parameter ) ) + if "variadicParameter" in desc: + self.variadicParameter = Variable( desc[ "variadicParameter" ] ) + else: + self.variadicParameter = None + if "request" in desc: + self.request = desc[ "request" ] + else: + self.request = None + + def ToJson( self ): + json = { + "name": self.name, + "type": self.type, + "group": self.group, + "isMutation": self.isMutation, + "mandatoryParameters": self.mandatoryParameters, + "optionalParameters": self.optionalParameters, + } + if self.variadicParameter is not None: + json[ "variadicParameter" ] = self.variadicParameter + if self.request is not None: + json[ "request" ] = self.request + return json + +class Collection: + def __init__( self, desc, ownerUrl ): + checkKeys( desc, [ "name", "singularName", "type" ], [ "addElement", "addSeveralElements", "createElement", "deleteList", "getElement", "getList", "hasElement", "removeElement", "removeSeveralElements", "setList", "url" ] ) + + if "url" in desc: + self.__url = desc[ "url" ] + else: + self.__url = ownerUrl + [ + { "type": "constant", "value": "/" + desc[ "name" ] }, + ] + + name = desc[ "name" ] if isinstance( desc[ "name" ], list ) else [ desc[ "name" ] ] + self.methods = list() + if "addElement" in desc: + assert desc[ "addElement" ] is True + self.methods.append( Function( + { "name": [ "add", "to" ] + name, "type": "void", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, + { + "request": { + "verb": "PUT", + "url": self.__url + [ + { "type": "constant", "value": "/" }, + { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, + ], + "information": "status", + } + } + ) ) + if "addSeveralElements" in desc: + assert desc[ "addSeveralElements" ] is True + self.methods.append( Function( + { "name": [ "add", "to" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, + { + "request": { + "verb": "POST", + "url": self.__url, + "information": "status", + "postParameters": True + } + } + ) ) + if "createElement" in desc: + self.methods.append( Function( + desc[ "createElement" ], + { "name": [ "create", desc[ "singularName" ] ], "type": desc[ "type" ], "group": desc[ "name" ] }, + { + "request": { + "verb": "POST", + "url": self.__url, + "information": "status", + "postParameters": True, + } + } + ) ) + if "deleteList" in desc: + assert desc[ "deleteList" ] is True + self.methods.append( Function( + { "name": [ "delete" ] + name, "type": "void", "group": desc[ "name" ] }, + { + "request": { + "verb": "DELETE", + "url": self.__url, + "information": "status", + } + } + ) ) + if "getElement" in desc: + if "url" in desc[ "getElement" ]: + urlForGetElement = desc[ "getElement" ][ "url" ] + else: + urlForGetElement = self.__url + [ + { "type": "constant", "value": "/" }, + { "type": "argument", "value": [ desc[ "getElement" ][ "parameter" ][ "name" ] ] }, + ] + + self.methods.append( Function( + desc[ "getElement" ], + { "name": [ "get", desc[ "singularName" ] ], "type": desc[ "type" ], "group": desc[ "name" ], "mandatoryParameters": [ desc[ "getElement" ][ "parameter" ] ] }, + { + "request": { + "verb": "GET", + "url": urlForGetElement, + "information": "data", + } + } + ) ) + if "getList" in desc: + self.methods.append( Function( + desc[ "getList" ] if desc[ "getList" ] is not True else dict(), + { "name": [ "get" ] + name, "type": { "cardinality": "list", "name": desc[ "type" ] }, "group": desc[ "name" ] }, + { + "request": { + "verb": "GET", + "url": self.__url, + "information": "data", + } + } + ) ) + if "hasElement" in desc: + assert desc[ "hasElement" ] is True + self.methods.append( Function( + { "name": [ "has", "in" ] + name, "type": "bool", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, + { + "request": { + "verb": "GET", + "url": self.__url + [ + { "type": "constant", "value": "/" }, + { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, + ], + "information": "status", + } + } + ) ) + if "removeElement" in desc: + assert desc[ "removeElement" ] is True + self.methods.append( Function( + { "name": [ "remove", "from" ] + name, "type": "void", "group": desc[ "name" ], "mandatoryParameters": [ { "name": desc[ "singularName" ], "type": desc[ "type" ] } ] }, + { + "request": { + "verb": "DELETE", + "url": self.__url + [ + { "type": "constant", "value": "/" }, + { "type": "argument", "value": [ desc[ "singularName" ], "_identity" ] }, + ], + "information": "status", + } + } + ) ) + if "removeSeveralElements" in desc: + assert desc[ "removeSeveralElements" ] is True + self.methods.append( Function( + { "name": [ "remove", "from" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, + { + "request": { + "verb": "DELETE", + "url": self.__url, + "information": "status", + "postParameters": True + } + } + ) ) + if "setList" in desc: + assert desc[ "setList" ] is True + self.methods.append( Function( + { "name": [ "set" ] + name, "type": "void", "group": desc[ "name" ], "variadicParameter": { "name": desc[ "singularName" ], "type": desc[ "type" ] } }, + { + "request": { + "verb": "PUT", + "url": self.__url, + "information": "status", + "postParameters": True, + } + } + ) ) + +class Class: + def __init__( self, desc ): + checkKeys( desc, [ "name", "attributes" ], [ "isCompletable", "url", "identity", "edit", "delete", "additionalMethods", "collections" ] ) + + self.name = desc[ "name" ] + self.attributes = sorted( + [ + Variable( attr ) + for attr in desc[ "attributes" ] + ], + key = lambda class_: class_.name + ) + self.isCompletable = "isCompletable" in desc and desc[ "isCompletable" ] + self.methods = [] + if "identity" in desc: + self.identity = desc[ "identity" ] + else: + self.identity = None + if "edit" in desc: + self.methods.append( Function( + desc[ "edit" ], + { "name": [ "edit" ], "type": "void", "group": "modification", "isMutation": True }, + { + "request": { + "verb": "PATCH", + "url": [ { "type": "constant", "value": "https://api.github.com/user" } if desc[ "name" ] == "AuthenticatedUser" else { "type": "attribute", "value": [ "url" ] } ], # @todo + "postParameters": True, # @todo + "information": "data", + }, + } + ) ) + if "delete" in desc: + self.methods.append( Function( + { "name": [ "delete" ], "type": "void", "group": "deletion" }, + { + "request": { + "verb": "DELETE", + "url": [ { "type": "attribute", "value": [ "url" ] } ], + "information": "data", + }, + } + ) ) + if "url" in desc: + url = desc[ "url" ] + else: + url = [ { "type": "attribute", "value": [ "url" ] } ] + if "collections" in desc: + for collection in [ Collection( collection, url ) for collection in desc[ "collections" ] ]: + self.methods += collection.methods + if "additionalMethods" in desc: + self.methods += [ Function( method ) for method in desc[ "additionalMethods" ] ] + + def ToJson( self ): + d = { + "name": self.name, + "attributes": self.attributes, + "methods": self.methods, + "isCompletable": self.isCompletable, + } + if self.identity is not None: + d[ "identity" ] = self.identity + return d + +class Description: + def __init__( self, desc ): + checkKeys( desc, [ "classes" ] ) + + self.classes = sorted( + [ + Class( class_ ) + for class_ in desc[ "classes" ] + ], + key = lambda class_: class_.name + ) + + def ToJson( self ): + return { + "classes": self.classes, + } + + def save( self, fileName ): + class Encoder( json.JSONEncoder ): + def default( self, obj ): + if hasattr( obj, "ToJson" ): + return obj.ToJson() + return json.JSONEncoder.default( self, obj ) + + with open( os.path.join( os.path.dirname( __file__ ), fileName ), "w" ) as f: + json.dump( self, f, indent = 4, cls = Encoder ) + +with open( os.path.join( os.path.dirname( __file__ ), "description.000.human_readable.json" ) ) as f: + description = Description( json.load( f ) ) + +description.save( "description.001.normalized.json" ) diff --git a/codegen/templates/GithubObject.MethodBody.DoRequest.py b/codegen/templates/GithubObject.MethodBody.DoRequest.py index 6075a0e2..dd57f8ae 100644 --- a/codegen/templates/GithubObject.MethodBody.DoRequest.py +++ b/codegen/templates/GithubObject.MethodBody.DoRequest.py @@ -1,122 +1,122 @@ -{% if method.variadicParameter %} - {% if method.variadicParameter.type.name != "@todo" %} - {% if method.variadicParameter.type.simple %} - {% if method.variadicParameter.type.name == "string" %} - assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], ( str, unicode ) ), {{ method.variadicParameter.name }}s - {% endif %} - {% if parameter.type.name == "integer" %} - assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], int ), {{ method.variadicParameter.name }}s - {% endif %} - {% if parameter.type.name == "bool" %} - assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], bool ), {{ method.variadicParameter.name }}s - {% endif %} - {% else %} - assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], {{ method.variadicParameter.type.name }}.{{ method.variadicParameter.type.name }} ), {{ method.variadicParameter.name }}s - {% endif %} - {% endif %} -{% else %} - {% for parameter in method.mandatoryParameters %} - {% if parameter.type.cardinality == "scalar" %} - - {% if parameter.type.simple %} - {% if parameter.type.name == "string" %} - assert isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "integer" %} - assert isinstance( {{ parameter.name }}, int ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "bool" %} - assert isinstance( {{ parameter.name }}, bool ), {{ parameter.name }} - {% endif %} - {% else %} - assert isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }} - {% endif %} - - {% else %} - - {% if parameter.type.simple %} - {% if parameter.type.name == "string" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], ( str, unicode ) ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "integer" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], int ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "bool" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], bool ) ), {{ parameter.name }} - {% endif %} - {% else %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], {{ parameter.type.name }}.{{ parameter.type.name }} ) ), {{ parameter.name }} - {% endif %} - - {% endif %} - {% endfor %} - {% for parameter in method.optionalParameters %} - {% if parameter.type.name != "@todo" %} - if {{ parameter.name }} is not DefaultValueForOptionalParameters: - {% endif %} - - {% if parameter.type.cardinality == "scalar" %} - - {% if parameter.type.simple %} - {% if parameter.type.name == "string" %} - assert isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "integer" %} - assert isinstance( {{ parameter.name }}, int ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "bool" %} - assert isinstance( {{ parameter.name }}, bool ), {{ parameter.name }} - {% endif %} - {% else %} - assert isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }} - {% endif %} - - {% else %} - - {% if parameter.type.simple %} - {% if parameter.type.name == "string" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], ( str, unicode ) ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "integer" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], int ) ), {{ parameter.name }} - {% endif %} - {% if parameter.type.name == "bool" %} - assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], bool ) ), {{ parameter.name }} - {% endif %} - {% else %} - assert isinstance( {{ parameter.name }}, list ) and ( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], {{ parameter.type.name }}.{{ parameter.type.name }} ) ), {{ parameter.name }} - {% endif %} - - {% endif %} - {% endfor %} -{% endif %} - -{% if method.request.postParameters %} - {% if method.variadicParameter %} - {% if method.variadicParameter.type.simple %} - post_parameters = {{ method.variadicParameter.name }}s - {% else %} - post_parameters = [ {{ method.variadicParameter.name }}._identity for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ] - {% endif %} - {% else %} - post_parameters = { - {% for parameter in method.mandatoryParameters %} - "{{ parameter.name }}": {{ parameter.name }}, - {% endfor %} - } - {% for parameter in method.optionalParameters %} - if {{ parameter.name }} is not DefaultValueForOptionalParameters: - post_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }} - {% endfor %} - {% endif %} -{% endif %} - - status, headers, data = self.__requester.request( - "{{ method.request.verb }}", - {% include "GithubObject.Concatenation.py" with concatenation=method.request.url only %}, -{% if method.request.postParameters %} - post_parameters -{% else %} - None -{% endif %} - ) +{% if method.variadicParameter %} + {% if method.variadicParameter.type.name != "@todo" %} + {% if method.variadicParameter.type.simple %} + {% if method.variadicParameter.type.name == "string" %} + assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], ( str, unicode ) ), {{ method.variadicParameter.name }}s + {% endif %} + {% if parameter.type.name == "integer" %} + assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], int ), {{ method.variadicParameter.name }}s + {% endif %} + {% if parameter.type.name == "bool" %} + assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], bool ), {{ method.variadicParameter.name }}s + {% endif %} + {% else %} + assert len( {{ method.variadicParameter.name }}s ) == 0 or isinstance( {{ method.variadicParameter.name }}s[ 0 ], {{ method.variadicParameter.type.name }}.{{ method.variadicParameter.type.name }} ), {{ method.variadicParameter.name }}s + {% endif %} + {% endif %} +{% else %} + {% for parameter in method.mandatoryParameters %} + {% if parameter.type.cardinality == "scalar" %} + + {% if parameter.type.simple %} + {% if parameter.type.name == "string" %} + assert isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "integer" %} + assert isinstance( {{ parameter.name }}, int ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "bool" %} + assert isinstance( {{ parameter.name }}, bool ), {{ parameter.name }} + {% endif %} + {% else %} + assert isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }} + {% endif %} + + {% else %} + + {% if parameter.type.simple %} + {% if parameter.type.name == "string" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], ( str, unicode ) ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "integer" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], int ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "bool" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], bool ) ), {{ parameter.name }} + {% endif %} + {% else %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], {{ parameter.type.name }}.{{ parameter.type.name }} ) ), {{ parameter.name }} + {% endif %} + + {% endif %} + {% endfor %} + {% for parameter in method.optionalParameters %} + {% if parameter.type.name != "@todo" %} + if {{ parameter.name }} is not DefaultValueForOptionalParameters: + {% endif %} + + {% if parameter.type.cardinality == "scalar" %} + + {% if parameter.type.simple %} + {% if parameter.type.name == "string" %} + assert isinstance( {{ parameter.name }}, ( str, unicode ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "integer" %} + assert isinstance( {{ parameter.name }}, int ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "bool" %} + assert isinstance( {{ parameter.name }}, bool ), {{ parameter.name }} + {% endif %} + {% else %} + assert isinstance( {{ parameter.name }}, {{ parameter.type.name }}.{{ parameter.type.name }} ), {{ parameter.name }} + {% endif %} + + {% else %} + + {% if parameter.type.simple %} + {% if parameter.type.name == "string" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], ( str, unicode ) ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "integer" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], int ) ), {{ parameter.name }} + {% endif %} + {% if parameter.type.name == "bool" %} + assert isinstance( {{ parameter.name }}, list ) and ( len( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], bool ) ), {{ parameter.name }} + {% endif %} + {% else %} + assert isinstance( {{ parameter.name }}, list ) and ( {{ parameter.name }} ) == 0 or isinstance( {{ parameter.name }}[ 0 ], {{ parameter.type.name }}.{{ parameter.type.name }} ) ), {{ parameter.name }} + {% endif %} + + {% endif %} + {% endfor %} +{% endif %} + +{% if method.request.postParameters %} + {% if method.variadicParameter %} + {% if method.variadicParameter.type.simple %} + post_parameters = {{ method.variadicParameter.name }}s + {% else %} + post_parameters = [ {{ method.variadicParameter.name }}._identity for {{ method.variadicParameter.name }} in {{ method.variadicParameter.name }}s ] + {% endif %} + {% else %} + post_parameters = { + {% for parameter in method.mandatoryParameters %} + "{{ parameter.name }}": {{ parameter.name }}, + {% endfor %} + } + {% for parameter in method.optionalParameters %} + if {{ parameter.name }} is not DefaultValueForOptionalParameters: + post_parameters[ "{{ parameter.name }}" ] = {{ parameter.name }} + {% endfor %} + {% endif %} +{% endif %} + + status, headers, data = self.__requester.request( + "{{ method.request.verb }}", + {% include "GithubObject.Concatenation.py" with concatenation=method.request.url only %}, +{% if method.request.postParameters %} + post_parameters +{% else %} + None +{% endif %} + ) diff --git a/codegen/templates/GithubObject.MethodBody.UseResult.py b/codegen/templates/GithubObject.MethodBody.UseResult.py index 9bd87eec..445ba662 100644 --- a/codegen/templates/GithubObject.MethodBody.UseResult.py +++ b/codegen/templates/GithubObject.MethodBody.UseResult.py @@ -1,38 +1,38 @@ -{% if method.isMutation %} - self.__useAttributes( data ) -{% endif %} - -{% if method.type.simple %} - -{% if method.type.cardinality == "scalar" %} - -{% if method.type.name == "@todo" %} - return data -{% endif %} - -{% if method.type.name == "bool" %} - return status == 204 -{% endif %} - -{% endif %} - -{% if method.type.cardinality == "list" %} - return data -{% endif %} - -{% else %} - -{% if method.type.cardinality == "scalar" %} - return {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__requester, data, completion = NoCompletion ) -{% endif %} - -{% if method.type.cardinality == "list" %} - return PaginatedList.PaginatedList( - {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}, - self.__requester, - headers, - data - ) -{% endif %} - -{% endif %} +{% if method.isMutation %} + self.__useAttributes( data ) +{% endif %} + +{% if method.type.simple %} + +{% if method.type.cardinality == "scalar" %} + +{% if method.type.name == "@todo" %} + return data +{% endif %} + +{% if method.type.name == "bool" %} + return status == 204 +{% endif %} + +{% endif %} + +{% if method.type.cardinality == "list" %} + return data +{% endif %} + +{% else %} + +{% if method.type.cardinality == "scalar" %} + return {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}( self.__requester, data, completion = NoCompletion ) +{% endif %} + +{% if method.type.cardinality == "list" %} + return PaginatedList.PaginatedList( + {% if method.type.name != class.name %}{{ method.type.name }}.{% endif %}{{ method.type.name }}, + self.__requester, + headers, + data + ) +{% endif %} + +{% endif %} diff --git a/test/Authorization.py b/test/Authorization.py index 8612b955..dca5b007 100644 --- a/test/Authorization.py +++ b/test/Authorization.py @@ -1,35 +1,35 @@ -import Framework - -class Authorization( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.authorization = self.g.get_user().get_authorization( 372259 ) - - def testAttributes( self ): - self.assertEqual( self.authorization.app, {u'url': u'http://developer.github.com/v3/oauth/#oauth-authorizations-api', u'name': u'GitHub API'} ) ### @todo - self.assertEqual( self.authorization.created_at, "2012-05-22T18:03:17Z" ) - self.assertEqual( self.authorization.id, 372259 ) - self.assertEqual( self.authorization.note, None ) - self.assertEqual( self.authorization.note_url, None ) - self.assertEqual( self.authorization.scopes, [] ) - self.assertEqual( self.authorization.token, "82459c4500086f8f0cc67d2936c17d1e27ad1c33" ) - self.assertEqual( self.authorization.updated_at, "2012-05-22T18:03:17Z" ) - self.assertEqual( self.authorization.url, "https://api.github.com/authorizations/372259" ) - - def testEdit( self ): - self.authorization.edit() - self.assertEqual( self.authorization.scopes, [] ) - self.authorization.edit( scopes = [ "user" ] ) - self.assertEqual( self.authorization.scopes, [ "user" ] ) - self.authorization.edit( add_scopes = [ "repo" ] ) - self.assertEqual( self.authorization.scopes, [ "user", "repo" ] ) - self.authorization.edit( remove_scopes = [ "repo" ] ) - self.assertEqual( self.authorization.scopes, [ "user" ] ) - self.assertEqual( self.authorization.note, None ) - self.assertEqual( self.authorization.note_url, None ) - self.authorization.edit( note = "Note created by PyGithub", note_url = "http://vincent-jacques.net/PyGithub" ) - self.assertEqual( self.authorization.note, "Note created by PyGithub" ) - self.assertEqual( self.authorization.note_url, "http://vincent-jacques.net/PyGithub" ) - - def testDelete( self ): - self.authorization.delete() +import Framework + +class Authorization( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.authorization = self.g.get_user().get_authorization( 372259 ) + + def testAttributes( self ): + self.assertEqual( self.authorization.app, {u'url': u'http://developer.github.com/v3/oauth/#oauth-authorizations-api', u'name': u'GitHub API'} ) ### @todo + self.assertEqual( self.authorization.created_at, "2012-05-22T18:03:17Z" ) + self.assertEqual( self.authorization.id, 372259 ) + self.assertEqual( self.authorization.note, None ) + self.assertEqual( self.authorization.note_url, None ) + self.assertEqual( self.authorization.scopes, [] ) + self.assertEqual( self.authorization.token, "82459c4500086f8f0cc67d2936c17d1e27ad1c33" ) + self.assertEqual( self.authorization.updated_at, "2012-05-22T18:03:17Z" ) + self.assertEqual( self.authorization.url, "https://api.github.com/authorizations/372259" ) + + def testEdit( self ): + self.authorization.edit() + self.assertEqual( self.authorization.scopes, [] ) + self.authorization.edit( scopes = [ "user" ] ) + self.assertEqual( self.authorization.scopes, [ "user" ] ) + self.authorization.edit( add_scopes = [ "repo" ] ) + self.assertEqual( self.authorization.scopes, [ "user", "repo" ] ) + self.authorization.edit( remove_scopes = [ "repo" ] ) + self.assertEqual( self.authorization.scopes, [ "user" ] ) + self.assertEqual( self.authorization.note, None ) + self.assertEqual( self.authorization.note_url, None ) + self.authorization.edit( note = "Note created by PyGithub", note_url = "http://vincent-jacques.net/PyGithub" ) + self.assertEqual( self.authorization.note, "Note created by PyGithub" ) + self.assertEqual( self.authorization.note_url, "http://vincent-jacques.net/PyGithub" ) + + def testDelete( self ): + self.authorization.delete() diff --git a/test/Download.py b/test/Download.py index 971e345f..d53149ff 100644 --- a/test/Download.py +++ b/test/Download.py @@ -1,31 +1,31 @@ -import Framework - -class Download( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.download = self.g.get_user().get_repo( "PyGithub" ).get_download( 242550 ) - - def testAttributes( self ): - self.assertEqual( self.download.accesskeyid, None ) - self.assertEqual( self.download.acl, None ) - self.assertEqual( self.download.bucket, None ) - self.assertEqual( self.download.content_type, "text/plain" ) - self.assertEqual( self.download.created_at, "2012-05-22T18:58:32Z" ) - self.assertEqual( self.download.description, None ) - self.assertEqual( self.download.download_count, 0 ) - self.assertEqual( self.download.expirationdate, None ) - self.assertEqual( self.download.html_url, "https://github.com/downloads/jacquev6/PyGithub/Foobar.txt" ) - self.assertEqual( self.download.id, 242550 ) - self.assertEqual( self.download.mime_type, None ) - self.assertEqual( self.download.name, "Foobar.txt" ) - self.assertEqual( self.download.path, None ) - self.assertEqual( self.download.policy, None ) - self.assertEqual( self.download.prefix, None ) - self.assertEqual( self.download.redirect, None ) - self.assertEqual( self.download.s3_url, None ) - self.assertEqual( self.download.signature, None ) - self.assertEqual( self.download.size, 1024 ) - self.assertEqual( self.download.url, "https://api.github.com/repos/jacquev6/PyGithub/downloads/242550" ) - - def testDelete( self ): - self.download.delete() +import Framework + +class Download( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.download = self.g.get_user().get_repo( "PyGithub" ).get_download( 242550 ) + + def testAttributes( self ): + self.assertEqual( self.download.accesskeyid, None ) + self.assertEqual( self.download.acl, None ) + self.assertEqual( self.download.bucket, None ) + self.assertEqual( self.download.content_type, "text/plain" ) + self.assertEqual( self.download.created_at, "2012-05-22T18:58:32Z" ) + self.assertEqual( self.download.description, None ) + self.assertEqual( self.download.download_count, 0 ) + self.assertEqual( self.download.expirationdate, None ) + self.assertEqual( self.download.html_url, "https://github.com/downloads/jacquev6/PyGithub/Foobar.txt" ) + self.assertEqual( self.download.id, 242550 ) + self.assertEqual( self.download.mime_type, None ) + self.assertEqual( self.download.name, "Foobar.txt" ) + self.assertEqual( self.download.path, None ) + self.assertEqual( self.download.policy, None ) + self.assertEqual( self.download.prefix, None ) + self.assertEqual( self.download.redirect, None ) + self.assertEqual( self.download.s3_url, None ) + self.assertEqual( self.download.signature, None ) + self.assertEqual( self.download.size, 1024 ) + self.assertEqual( self.download.url, "https://api.github.com/repos/jacquev6/PyGithub/downloads/242550" ) + + def testDelete( self ): + self.download.delete() diff --git a/test/Event.py b/test/Event.py index 8cdf2a65..77643779 100644 --- a/test/Event.py +++ b/test/Event.py @@ -1,16 +1,16 @@ -import Framework - -class Event( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.event = self.g.get_user( "jacquev6" ).get_events()[ 0 ] - - def testAttributes( self ): - self.assertEqual( self.event.actor.login, "jacquev6" ) - self.assertEqual( self.event.created_at, "2012-05-26T10:01:39Z" ) - self.assertEqual( self.event.id, "1556114751" ) - self.assertEqual( self.event.org, None ) - self.assertEqual( self.event.payload, {u'commits': [{u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'sha': u'5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'message': u'Implement the three authentication schemes', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/cb0313157bf904f2d364377d35d9397b269547a5', u'sha': u'cb0313157bf904f2d364377d35d9397b269547a5', u'message': u"Merge branch 'topic/Authentication' into develop", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'sha': u'0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'message': u'Publish version 0.7', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'sha': u'ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'message': u"Merge branch 'develop'", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/3a3bf4763192ee1234eb0557628133e06f3dfc76', u'sha': u'3a3bf4763192ee1234eb0557628133e06f3dfc76', u'message': u"Merge branch 'master' into topic/RewriteWithGeneratedCode\n\nConflicts:\n\tgithub/Github.py\n\tgithub/Requester.py", u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/608f17794664f61693a3dc05e6056fea8fbef0ff', u'sha': u'608f17794664f61693a3dc05e6056fea8fbef0ff', u'message': u'Restore some form of Authorization header in replay data', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'sha': u'2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'message': u'Allow test without pre-set-up Github', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5b97389988b6fe43e15a079702f6f1671257fb28', u'sha': u'5b97389988b6fe43e15a079702f6f1671257fb28', u'message': u'Test three authentication schemes', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/12747613c5ec00deccf296b8619ad507f7050475', u'sha': u'12747613c5ec00deccf296b8619ad507f7050475', u'message': u'Test Issue.getComments', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2982fa96c5ca75abe717d974d83f9135d664232e', u'sha': u'2982fa96c5ca75abe717d974d83f9135d664232e', u'message': u'Test the new Repository.full_name attribute', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/619eae8d51c5988f0d2889fc767fa677438ba95d', u'sha': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'message': u'Improve coverage of AuthenticatedUser', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}], u'head': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'push_id': 80673538, u'ref': u'refs/heads/topic/RewriteWithGeneratedCode', u'size': 11} ) ### @todo - self.assertEqual( self.event.public, True ) - self.assertEqual( self.event.repo.name, "jacquev6/PyGithub" ) - self.assertEqual( self.event.type, "PushEvent" ) +import Framework + +class Event( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.event = self.g.get_user( "jacquev6" ).get_events()[ 0 ] + + def testAttributes( self ): + self.assertEqual( self.event.actor.login, "jacquev6" ) + self.assertEqual( self.event.created_at, "2012-05-26T10:01:39Z" ) + self.assertEqual( self.event.id, "1556114751" ) + self.assertEqual( self.event.org, None ) + self.assertEqual( self.event.payload, {u'commits': [{u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'sha': u'5bb654d26dd014d36794acd1e6ecf3736f12aad7', u'message': u'Implement the three authentication schemes', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/cb0313157bf904f2d364377d35d9397b269547a5', u'sha': u'cb0313157bf904f2d364377d35d9397b269547a5', u'message': u"Merge branch 'topic/Authentication' into develop", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'sha': u'0cec0d25e606c023a62a4fc7cdc815309ebf6d16', u'message': u'Publish version 0.7', u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'sha': u'ecda065e01876209d2bdf5fe4e91cee8ffaa9ff7', u'message': u"Merge branch 'develop'", u'distinct': False, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/3a3bf4763192ee1234eb0557628133e06f3dfc76', u'sha': u'3a3bf4763192ee1234eb0557628133e06f3dfc76', u'message': u"Merge branch 'master' into topic/RewriteWithGeneratedCode\n\nConflicts:\n\tgithub/Github.py\n\tgithub/Requester.py", u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/608f17794664f61693a3dc05e6056fea8fbef0ff', u'sha': u'608f17794664f61693a3dc05e6056fea8fbef0ff', u'message': u'Restore some form of Authorization header in replay data', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'sha': u'2c04b8adbd91d38eef4f0767337ab7a12b2f684b', u'message': u'Allow test without pre-set-up Github', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/5b97389988b6fe43e15a079702f6f1671257fb28', u'sha': u'5b97389988b6fe43e15a079702f6f1671257fb28', u'message': u'Test three authentication schemes', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/12747613c5ec00deccf296b8619ad507f7050475', u'sha': u'12747613c5ec00deccf296b8619ad507f7050475', u'message': u'Test Issue.getComments', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/2982fa96c5ca75abe717d974d83f9135d664232e', u'sha': u'2982fa96c5ca75abe717d974d83f9135d664232e', u'message': u'Test the new Repository.full_name attribute', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}, {u'url': u'https://api.github.com/repos/jacquev6/PyGithub/commits/619eae8d51c5988f0d2889fc767fa677438ba95d', u'sha': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'message': u'Improve coverage of AuthenticatedUser', u'distinct': True, u'author': {u'name': u'Vincent Jacques', u'email': u'vincent@vincent-jacques.net'}}], u'head': u'619eae8d51c5988f0d2889fc767fa677438ba95d', u'push_id': 80673538, u'ref': u'refs/heads/topic/RewriteWithGeneratedCode', u'size': 11} ) ### @todo + self.assertEqual( self.event.public, True ) + self.assertEqual( self.event.repo.name, "jacquev6/PyGithub" ) + self.assertEqual( self.event.type, "PushEvent" ) diff --git a/test/Framework.py b/test/Framework.py index a0426047..b0cbd775 100644 --- a/test/Framework.py +++ b/test/Framework.py @@ -1,146 +1,146 @@ -import os -import sys -import unittest -import httplib -import traceback -import itertools - -sys.path = [ os.path.join( os.path.dirname( __file__ ), "..", "src" ) ] + sys.path -import github - -class FakeHttpResponse: - def __init__( self, status, headers, output ): - self.status = status - self.__headers = headers - self.__output = output - - def getheaders( self ): - return self.__headers - - def read( self ): - return self.__output - -def fixAuthorizationHeader( headers ): - if "Authorization" in headers: - if headers[ "Authorization" ].startswith( "token " ): - headers[ "Authorization" ] = "token private_token_removed" - elif headers[ "Authorization" ].startswith( "Basic " ): - headers[ "Authorization" ] = "Basic login_and_password_removed" - else: - del headers[ "Authorization" ] # Do not let sensitive info in git :-p - -class RecordingHttpsConnection: - __realHttpsConnection = httplib.HTTPSConnection - - def __init__( self, file, *args, **kwds ): - self.__file = file - self.__cnx = self.__realHttpsConnection( *args, **kwds ) - - def request( self, verb, url, input, headers ): - print verb, url, input, headers, - self.__cnx.request( verb, url, input, headers ) - fixAuthorizationHeader( headers ) - self.__file.write( verb + " " + url + " " + str( headers ) + " " + input + "\n" ) - - def getresponse( self ): - res = self.__cnx.getresponse() - - status = res.status - print "=>", status - headers = res.getheaders() - output = res.read() - - self.__file.write( str( status ) + "\n" ) - self.__file.write( str( headers ) + "\n" ) - self.__file.write( str( output ) + "\n" ) - - return FakeHttpResponse( status, headers, output ) - - def close( self ): - self.__file.write( "\n" ) - return self.__cnx.close() - -class ReplayingHttpsConnection: - def __init__( self, testCase, file ): - self.__testCase = testCase - self.__file = file - - def request( self, verb, url, input, headers ): - fixAuthorizationHeader( headers ) - expectation = self.__file.readline().strip() - self.__testCase.assertEqual( verb + " " + url + " " + str( headers ) + " " + input, expectation ) - - def getresponse( self ): - status = int( self.__file.readline().strip() ) - headers = eval( self.__file.readline().strip() ) - output = self.__file.readline().strip() - - return FakeHttpResponse( status, headers, output ) - - def close( self ): - self.__file.readline() - -class BasicTestCase( unittest.TestCase ): - recordMode = False - - def setUp( self ): - unittest.TestCase.setUp( self ) - self.__fileName = "" - self.__file = None - if self.recordMode: - httplib.HTTPSConnection = lambda *args, **kwds: RecordingHttpsConnection( self.__openFile( "w" ), *args, **kwds ) - import GithubCredentials - self.login = GithubCredentials.login - self.password = GithubCredentials.password - self.oauth_token = GithubCredentials.oauth_token - else: - httplib.HTTPSConnection = lambda *args, **kwds: ReplayingHttpsConnection( self, self.__openFile( "r" ) ) - self.login = "login" - self.password = "password" - self.oauth_token = "oauth_token" - - def tearDown( self ): - unittest.TestCase.tearDown( self ) - self.__closeReplayFileIfNeeded() - - def __openFile( self, mode ): - for ( _, _, functionName, _ ) in traceback.extract_stack(): - if functionName.startswith( "test" ) and functionName != "test" or functionName == "setUp" or functionName == "tearDown": - fileName = os.path.join( os.path.dirname( __file__ ), "ReplayData", self.__class__.__name__ + "." + functionName + ".txt" ) - if fileName != self.__fileName: - self.__closeReplayFileIfNeeded() - self.__fileName = fileName - self.__file = open( self.__fileName, mode ) - return self.__file - - def __closeReplayFileIfNeeded( self ): - if self.__file is not None: - if not self.recordMode: - self.assertEqual( self.__file.readline(), "" ) - self.__file.close() - - def assertListKeyEqual( self, elements, key, expectedKeys ): - realKeys = [ key( element ) for element in elements ] - self.assertEqual( realKeys, expectedKeys ) - - def assertListKeyBegin( self, elements, key, expectedKeys ): - def take( sequence, length ): - taken = list() - for element in elements: - taken.append( element ) - if len( taken ) >= length: - break - return taken - realKeys = [ key( element ) for element in take( elements, len( expectedKeys ) ) ] - self.assertEqual( realKeys, expectedKeys ) - -class TestCase( BasicTestCase ): - def setUp( self ): - BasicTestCase.setUp( self ) - self.g = github.Github( self.login, self.password ) - -def main(): - if "--record" in sys.argv: - BasicTestCase.recordMode = True - - unittest.main( argv = [ arg for arg in sys.argv if arg != "--record" ] ) +import os +import sys +import unittest +import httplib +import traceback +import itertools + +sys.path = [ os.path.join( os.path.dirname( __file__ ), "..", "src" ) ] + sys.path +import github + +class FakeHttpResponse: + def __init__( self, status, headers, output ): + self.status = status + self.__headers = headers + self.__output = output + + def getheaders( self ): + return self.__headers + + def read( self ): + return self.__output + +def fixAuthorizationHeader( headers ): + if "Authorization" in headers: + if headers[ "Authorization" ].startswith( "token " ): + headers[ "Authorization" ] = "token private_token_removed" + elif headers[ "Authorization" ].startswith( "Basic " ): + headers[ "Authorization" ] = "Basic login_and_password_removed" + else: + del headers[ "Authorization" ] # Do not let sensitive info in git :-p + +class RecordingHttpsConnection: + __realHttpsConnection = httplib.HTTPSConnection + + def __init__( self, file, *args, **kwds ): + self.__file = file + self.__cnx = self.__realHttpsConnection( *args, **kwds ) + + def request( self, verb, url, input, headers ): + print verb, url, input, headers, + self.__cnx.request( verb, url, input, headers ) + fixAuthorizationHeader( headers ) + self.__file.write( verb + " " + url + " " + str( headers ) + " " + input + "\n" ) + + def getresponse( self ): + res = self.__cnx.getresponse() + + status = res.status + print "=>", status + headers = res.getheaders() + output = res.read() + + self.__file.write( str( status ) + "\n" ) + self.__file.write( str( headers ) + "\n" ) + self.__file.write( str( output ) + "\n" ) + + return FakeHttpResponse( status, headers, output ) + + def close( self ): + self.__file.write( "\n" ) + return self.__cnx.close() + +class ReplayingHttpsConnection: + def __init__( self, testCase, file ): + self.__testCase = testCase + self.__file = file + + def request( self, verb, url, input, headers ): + fixAuthorizationHeader( headers ) + expectation = self.__file.readline().strip() + self.__testCase.assertEqual( verb + " " + url + " " + str( headers ) + " " + input, expectation ) + + def getresponse( self ): + status = int( self.__file.readline().strip() ) + headers = eval( self.__file.readline().strip() ) + output = self.__file.readline().strip() + + return FakeHttpResponse( status, headers, output ) + + def close( self ): + self.__file.readline() + +class BasicTestCase( unittest.TestCase ): + recordMode = False + + def setUp( self ): + unittest.TestCase.setUp( self ) + self.__fileName = "" + self.__file = None + if self.recordMode: + httplib.HTTPSConnection = lambda *args, **kwds: RecordingHttpsConnection( self.__openFile( "w" ), *args, **kwds ) + import GithubCredentials + self.login = GithubCredentials.login + self.password = GithubCredentials.password + self.oauth_token = GithubCredentials.oauth_token + else: + httplib.HTTPSConnection = lambda *args, **kwds: ReplayingHttpsConnection( self, self.__openFile( "r" ) ) + self.login = "login" + self.password = "password" + self.oauth_token = "oauth_token" + + def tearDown( self ): + unittest.TestCase.tearDown( self ) + self.__closeReplayFileIfNeeded() + + def __openFile( self, mode ): + for ( _, _, functionName, _ ) in traceback.extract_stack(): + if functionName.startswith( "test" ) and functionName != "test" or functionName == "setUp" or functionName == "tearDown": + fileName = os.path.join( os.path.dirname( __file__ ), "ReplayData", self.__class__.__name__ + "." + functionName + ".txt" ) + if fileName != self.__fileName: + self.__closeReplayFileIfNeeded() + self.__fileName = fileName + self.__file = open( self.__fileName, mode ) + return self.__file + + def __closeReplayFileIfNeeded( self ): + if self.__file is not None: + if not self.recordMode: + self.assertEqual( self.__file.readline(), "" ) + self.__file.close() + + def assertListKeyEqual( self, elements, key, expectedKeys ): + realKeys = [ key( element ) for element in elements ] + self.assertEqual( realKeys, expectedKeys ) + + def assertListKeyBegin( self, elements, key, expectedKeys ): + def take( sequence, length ): + taken = list() + for element in elements: + taken.append( element ) + if len( taken ) >= length: + break + return taken + realKeys = [ key( element ) for element in take( elements, len( expectedKeys ) ) ] + self.assertEqual( realKeys, expectedKeys ) + +class TestCase( BasicTestCase ): + def setUp( self ): + BasicTestCase.setUp( self ) + self.g = github.Github( self.login, self.password ) + +def main(): + if "--record" in sys.argv: + BasicTestCase.recordMode = True + + unittest.main( argv = [ arg for arg in sys.argv if arg != "--record" ] ) diff --git a/test/Gist.py b/test/Gist.py index 946d3e85..4f4e3166 100644 --- a/test/Gist.py +++ b/test/Gist.py @@ -1,66 +1,66 @@ -import Framework - -class Gist( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.gist = self.g.get_gist( "2729810" ) - - def testAttributes( self ): - self.assertEquals( self.gist.comments, 0 ) - self.assertEquals( self.gist.created_at, "2012-02-29T16:47:12Z" ) - self.assertEquals( self.gist.description, "How to error 500 Github API v3, as requested by Rick (GitHub Staff)" ) - self.assertEquals( self.gist.files, {u'fail_github.py': {u'raw_url': u'https://gist.github.com/raw/2729810/2fb3aa84e0efa50dc0f4c18b5df5b7b9ab27076b/fail_github.py', u'language': u'Python', u'filename': u'fail_github.py', u'content': u'import httplib\nimport base64\nimport json\n\nlogin = ""\npassword = ""\norgName = ""\nrepoName = "FailGithubApi"\n\ndef doRequest( verb, url, input ):\n input = json.dumps( input )\n cnx = httplib.HTTPSConnection( "api.github.com", strict = True )\n cnx.request( verb, url, input, { "Authorization" : "Basic " + base64.b64encode( login + ":" + password ).replace( \'\\n\', \'\' ) } )\n response = cnx.getresponse()\n status = response.status\n output = response.read()\n cnx.close()\n print verb, url, input, "=>", status, output\n print\n if status < 200 or status >= 300:\n exit( 1 )\n return json.loads( output )\n\n# Create a repo\ndoRequest( "POST", "/user/repos", { "name": repoName } )\n\n# Create a blob, a tree, a commit and the master branch\nb = doRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( login, repoName ),\n { "content": "Content of the blob", "encoding": "latin1" }\n)\nt = doRequest(\n "POST", "/repos/%s/%s/git/trees" % ( login, repoName ),\n { "tree" : [ { "path": "foo.bar", "type": "blob", "mode": "100644", "sha": b["sha"] } ] }\n)\nc = doRequest(\n "POST", "/repos/%s/%s/git/commits" % ( login, repoName ),\n { "parents": [], "message": "Message of the commit", "tree": t["sha"] }\n)\ndoRequest(\n "POST", "/repos/%s/%s/git/refs" % ( login, repoName ),\n { "ref": "refs/heads/master", "sha": c["sha"] }\n)\n\n# Fork the repo\ndoRequest( "POST", "/repos/%s/%s/forks?org=%s" % ( login, repoName, orgName ), None )\n\n# Create a new blob => BOOM error 500\ndoRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( orgName, repoName ),\n { "content": "Content of the new blob", "encoding": "latin1" }\n)\n', u'type': u'application/python', u'size': 1636}} ) ### @todo - self.assertEquals( self.gist.forks, [] ) - self.assertEquals( self.gist.git_pull_url, "git://gist.github.com/2729810.git" ) - self.assertEquals( self.gist.git_push_url, "git@gist.github.com:2729810.git" ) - self.assertEquals( len( self.gist.history ), 1 ) - self.assertEquals( self.gist.history[ 0 ].change_status.additions, 52 ) - self.assertEquals( self.gist.history[ 0 ].change_status.deletions, 0 ) - self.assertEquals( self.gist.history[ 0 ].change_status.total, 52 ) - self.assertEquals( self.gist.history[ 0 ].committed_at, "2012-02-29T16:47:12Z" ) - self.assertEquals( self.gist.history[ 0 ].url, "https://api.github.com/gists/2729810/a40de483e42ba33bda308371c0ef8383db73be9e" ) - self.assertEquals( self.gist.history[ 0 ].user.login, "jacquev6" ) - self.assertEquals( self.gist.history[ 0 ].version, "a40de483e42ba33bda308371c0ef8383db73be9e" ) - self.assertEquals( self.gist.html_url, "https://gist.github.com/2729810" ) - self.assertEquals( self.gist.id, "2729810" ) - self.assertEquals( self.gist.public, True ) - self.assertEquals( self.gist.updated_at, "2012-02-29T16:47:12Z" ) - self.assertEquals( self.gist.url, "https://api.github.com/gists/2729810" ) - self.assertEquals( self.gist.user.login, "jacquev6" ) - - def testEditWithoutParameters( self ): - self.gist.edit() - self.assertEquals( self.gist.description, "Gist created by PyGithub" ) - self.assertEquals( self.gist.updated_at, "2012-05-19T07:00:58Z" ) - - def testEditWithAllParameters( self ): - self.gist.edit( "Description edited by PyGithub", { "barbaz.txt": { "content": "File also created by PyGithub" } } ) - self.assertEquals( self.gist.description, "Description edited by PyGithub" ) - self.assertEquals( self.gist.updated_at, "2012-05-19T07:06:10Z" ) - self.assertEquals( self.gist.files, {u'foobar.txt': {u'raw_url': u'https://gist.github.com/raw/2729810/73a1c7f17aa0ad5d7cbb5a8ca033ce47d3d23197/foobar.txt', u'language': u'Text', u'filename': u'foobar.txt', u'content': u'File created by PyGithub', u'type': u'text/plain', u'size': 24}, u'barbaz.txt': {u'raw_url': u'https://gist.github.com/raw/2729810/92be1df4e473d2541c5c166ad145a39d0324de8b/barbaz.txt', u'language': u'Text', u'filename': u'barbaz.txt', u'content': u'File also created by PyGithub', u'type': u'text/plain', u'size': 29}} ) # Notice that the file is added, not replacing ### @todo - - def testCreateComment( self ): - comment = self.gist.create_comment( "Comment created by PyGithub" ) - self.assertEquals( comment.id, 323629 ) - - def testGetComments( self ): - for comment in self.gist.get_comments(): # There is only one comment - self.assertEquals( comment.id, 323637 ) ### @todo use assertListKeyEqual - - def testStarring( self ): - self.assertFalse( self.gist.is_starred() ) - self.gist.set_starred() - self.assertTrue( self.gist.is_starred() ) - self.gist.reset_starred() - self.assertFalse( self.gist.is_starred() ) - - def testFork( self ): - gist = self.g.get_gist( "2729818" ) # Random gist - myGist = gist.create_fork() - self.assertEquals( myGist.id, "2729865" ) - self.assertEquals( myGist.fork_of, None ) # WTF - sameGist = self.g.get_gist( "2729865" ) - self.assertEquals( sameGist.fork_of.id, "2729818" ) - - def testDelete( self ): - self.gist.delete() +import Framework + +class Gist( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.gist = self.g.get_gist( "2729810" ) + + def testAttributes( self ): + self.assertEquals( self.gist.comments, 0 ) + self.assertEquals( self.gist.created_at, "2012-02-29T16:47:12Z" ) + self.assertEquals( self.gist.description, "How to error 500 Github API v3, as requested by Rick (GitHub Staff)" ) + self.assertEquals( self.gist.files, {u'fail_github.py': {u'raw_url': u'https://gist.github.com/raw/2729810/2fb3aa84e0efa50dc0f4c18b5df5b7b9ab27076b/fail_github.py', u'language': u'Python', u'filename': u'fail_github.py', u'content': u'import httplib\nimport base64\nimport json\n\nlogin = ""\npassword = ""\norgName = ""\nrepoName = "FailGithubApi"\n\ndef doRequest( verb, url, input ):\n input = json.dumps( input )\n cnx = httplib.HTTPSConnection( "api.github.com", strict = True )\n cnx.request( verb, url, input, { "Authorization" : "Basic " + base64.b64encode( login + ":" + password ).replace( \'\\n\', \'\' ) } )\n response = cnx.getresponse()\n status = response.status\n output = response.read()\n cnx.close()\n print verb, url, input, "=>", status, output\n print\n if status < 200 or status >= 300:\n exit( 1 )\n return json.loads( output )\n\n# Create a repo\ndoRequest( "POST", "/user/repos", { "name": repoName } )\n\n# Create a blob, a tree, a commit and the master branch\nb = doRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( login, repoName ),\n { "content": "Content of the blob", "encoding": "latin1" }\n)\nt = doRequest(\n "POST", "/repos/%s/%s/git/trees" % ( login, repoName ),\n { "tree" : [ { "path": "foo.bar", "type": "blob", "mode": "100644", "sha": b["sha"] } ] }\n)\nc = doRequest(\n "POST", "/repos/%s/%s/git/commits" % ( login, repoName ),\n { "parents": [], "message": "Message of the commit", "tree": t["sha"] }\n)\ndoRequest(\n "POST", "/repos/%s/%s/git/refs" % ( login, repoName ),\n { "ref": "refs/heads/master", "sha": c["sha"] }\n)\n\n# Fork the repo\ndoRequest( "POST", "/repos/%s/%s/forks?org=%s" % ( login, repoName, orgName ), None )\n\n# Create a new blob => BOOM error 500\ndoRequest(\n "POST", "/repos/%s/%s/git/blobs" % ( orgName, repoName ),\n { "content": "Content of the new blob", "encoding": "latin1" }\n)\n', u'type': u'application/python', u'size': 1636}} ) ### @todo + self.assertEquals( self.gist.forks, [] ) + self.assertEquals( self.gist.git_pull_url, "git://gist.github.com/2729810.git" ) + self.assertEquals( self.gist.git_push_url, "git@gist.github.com:2729810.git" ) + self.assertEquals( len( self.gist.history ), 1 ) + self.assertEquals( self.gist.history[ 0 ].change_status.additions, 52 ) + self.assertEquals( self.gist.history[ 0 ].change_status.deletions, 0 ) + self.assertEquals( self.gist.history[ 0 ].change_status.total, 52 ) + self.assertEquals( self.gist.history[ 0 ].committed_at, "2012-02-29T16:47:12Z" ) + self.assertEquals( self.gist.history[ 0 ].url, "https://api.github.com/gists/2729810/a40de483e42ba33bda308371c0ef8383db73be9e" ) + self.assertEquals( self.gist.history[ 0 ].user.login, "jacquev6" ) + self.assertEquals( self.gist.history[ 0 ].version, "a40de483e42ba33bda308371c0ef8383db73be9e" ) + self.assertEquals( self.gist.html_url, "https://gist.github.com/2729810" ) + self.assertEquals( self.gist.id, "2729810" ) + self.assertEquals( self.gist.public, True ) + self.assertEquals( self.gist.updated_at, "2012-02-29T16:47:12Z" ) + self.assertEquals( self.gist.url, "https://api.github.com/gists/2729810" ) + self.assertEquals( self.gist.user.login, "jacquev6" ) + + def testEditWithoutParameters( self ): + self.gist.edit() + self.assertEquals( self.gist.description, "Gist created by PyGithub" ) + self.assertEquals( self.gist.updated_at, "2012-05-19T07:00:58Z" ) + + def testEditWithAllParameters( self ): + self.gist.edit( "Description edited by PyGithub", { "barbaz.txt": { "content": "File also created by PyGithub" } } ) + self.assertEquals( self.gist.description, "Description edited by PyGithub" ) + self.assertEquals( self.gist.updated_at, "2012-05-19T07:06:10Z" ) + self.assertEquals( self.gist.files, {u'foobar.txt': {u'raw_url': u'https://gist.github.com/raw/2729810/73a1c7f17aa0ad5d7cbb5a8ca033ce47d3d23197/foobar.txt', u'language': u'Text', u'filename': u'foobar.txt', u'content': u'File created by PyGithub', u'type': u'text/plain', u'size': 24}, u'barbaz.txt': {u'raw_url': u'https://gist.github.com/raw/2729810/92be1df4e473d2541c5c166ad145a39d0324de8b/barbaz.txt', u'language': u'Text', u'filename': u'barbaz.txt', u'content': u'File also created by PyGithub', u'type': u'text/plain', u'size': 29}} ) # Notice that the file is added, not replacing ### @todo + + def testCreateComment( self ): + comment = self.gist.create_comment( "Comment created by PyGithub" ) + self.assertEquals( comment.id, 323629 ) + + def testGetComments( self ): + for comment in self.gist.get_comments(): # There is only one comment + self.assertEquals( comment.id, 323637 ) ### @todo use assertListKeyEqual + + def testStarring( self ): + self.assertFalse( self.gist.is_starred() ) + self.gist.set_starred() + self.assertTrue( self.gist.is_starred() ) + self.gist.reset_starred() + self.assertFalse( self.gist.is_starred() ) + + def testFork( self ): + gist = self.g.get_gist( "2729818" ) # Random gist + myGist = gist.create_fork() + self.assertEquals( myGist.id, "2729865" ) + self.assertEquals( myGist.fork_of, None ) # WTF + sameGist = self.g.get_gist( "2729865" ) + self.assertEquals( sameGist.fork_of.id, "2729818" ) + + def testDelete( self ): + self.gist.delete() diff --git a/test/GistComment.py b/test/GistComment.py index 5132f724..aa97750b 100644 --- a/test/GistComment.py +++ b/test/GistComment.py @@ -1,22 +1,22 @@ -import Framework - -class GistComment( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.comment = self.g.get_gist( "2729810" ).get_comment( 323629 ) - - def testAttributes( self ): ### @todo Move - self.assertEquals( self.comment.body, "Comment created by PyGithub" ) - self.assertEquals( self.comment.created_at, "2012-05-19T07:07:57Z" ) - self.assertEquals( self.comment.id, 323629 ) - self.assertEquals( self.comment.updated_at, "2012-05-19T07:07:57Z" ) - self.assertEquals( self.comment.url, "https://api.github.com/gists/comments/323629" ) - self.assertEquals( self.comment.user.login, "jacquev6" ) - - def testEdit( self ): ### @todo Move - self.comment.edit( "Comment edited by PyGithub" ) - self.assertEquals( self.comment.body, "Comment edited by PyGithub" ) - self.assertEquals( self.comment.updated_at, "2012-05-19T07:12:32Z" ) - - def testDelete( self ): - self.comment.delete() +import Framework + +class GistComment( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.comment = self.g.get_gist( "2729810" ).get_comment( 323629 ) + + def testAttributes( self ): ### @todo Move + self.assertEquals( self.comment.body, "Comment created by PyGithub" ) + self.assertEquals( self.comment.created_at, "2012-05-19T07:07:57Z" ) + self.assertEquals( self.comment.id, 323629 ) + self.assertEquals( self.comment.updated_at, "2012-05-19T07:07:57Z" ) + self.assertEquals( self.comment.url, "https://api.github.com/gists/comments/323629" ) + self.assertEquals( self.comment.user.login, "jacquev6" ) + + def testEdit( self ): ### @todo Move + self.comment.edit( "Comment edited by PyGithub" ) + self.assertEquals( self.comment.body, "Comment edited by PyGithub" ) + self.assertEquals( self.comment.updated_at, "2012-05-19T07:12:32Z" ) + + def testDelete( self ): + self.comment.delete() diff --git a/test/Github.py b/test/Github.py index 682558af..62a480a2 100644 --- a/test/Github.py +++ b/test/Github.py @@ -1,5 +1,5 @@ -import Framework - -class Github( Framework.TestCase ): - def testGetGists( self ): - self.assertListKeyBegin( self.g.get_gists(), lambda g: g.id, [ "2729695", "2729656", "2729597", "2729584", "2729569", "2729554", "2729543", "2729537", "2729536", "2729533", "2729525", "2729522", "2729519", "2729515", "2729506", "2729487", "2729484", "2729482", "2729441", "2729432", "2729420", "2729398", "2729372", "2729371", "2729351", "2729346", "2729316", "2729304", "2729296", "2729276", "2729272", "2729265", "2729195", "2729160", "2729143", "2729127", "2729119", "2729113", "2729103", "2729069", "2729059", "2729051", "2729029", "2729027", "2729026", "2729022", "2729002", "2728985", "2728979", "2728964", "2728937", "2728933", "2728884", "2728869", "2728866", "2728855", "2728854", "2728853", "2728846", "2728825", "2728814", "2728813", "2728812", "2728805", "2728802", "2728800", "2728798", "2728797", "2728796", "2728793", "2728758", "2728754", "2728751", "2728748", "2728721", "2728716", "2728715", "2728705", "2728701", "2728699", "2728697", "2728688", "2728683", "2728677", "2728649", "2728640", "2728625", "2728620", "2728615", "2728614", "2728565", "2728564", "2728554", "2728523", "2728519", "2728511", "2728497", "2728496", "2728495", "2728487" ] ) +import Framework + +class Github( Framework.TestCase ): + def testGetGists( self ): + self.assertListKeyBegin( self.g.get_gists(), lambda g: g.id, [ "2729695", "2729656", "2729597", "2729584", "2729569", "2729554", "2729543", "2729537", "2729536", "2729533", "2729525", "2729522", "2729519", "2729515", "2729506", "2729487", "2729484", "2729482", "2729441", "2729432", "2729420", "2729398", "2729372", "2729371", "2729351", "2729346", "2729316", "2729304", "2729296", "2729276", "2729272", "2729265", "2729195", "2729160", "2729143", "2729127", "2729119", "2729113", "2729103", "2729069", "2729059", "2729051", "2729029", "2729027", "2729026", "2729022", "2729002", "2728985", "2728979", "2728964", "2728937", "2728933", "2728884", "2728869", "2728866", "2728855", "2728854", "2728853", "2728846", "2728825", "2728814", "2728813", "2728812", "2728805", "2728802", "2728800", "2728798", "2728797", "2728796", "2728793", "2728758", "2728754", "2728751", "2728748", "2728721", "2728716", "2728715", "2728705", "2728701", "2728699", "2728697", "2728688", "2728683", "2728677", "2728649", "2728640", "2728625", "2728620", "2728615", "2728614", "2728565", "2728564", "2728554", "2728523", "2728519", "2728511", "2728497", "2728496", "2728495", "2728487" ] ) diff --git a/test/Issue.py b/test/Issue.py index c0a781c0..159d19d3 100644 --- a/test/Issue.py +++ b/test/Issue.py @@ -1,73 +1,73 @@ -import Framework - -class Issue( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.repo = self.g.get_user().get_repo( "PyGithub" ) - self.issue = self.repo.get_issue( 28 ) - - def testAttributes( self ): - self.assertEqual( self.issue.assignee.login, "jacquev6" ) - self.assertEqual( self.issue.body, "Body edited by PyGithub" ) - self.assertEqual( self.issue.closed_at, "2012-05-26T14:59:33Z" ) - self.assertEqual( self.issue.closed_by.login, "jacquev6" ) - self.assertEqual( self.issue.comments, 0 ) - self.assertEqual( self.issue.created_at, "2012-05-19T10:38:23Z" ) - self.assertEqual( self.issue.html_url, "https://github.com/jacquev6/PyGithub/issues/28" ) - self.assertEqual( self.issue.id, 4653757 ) - self.assertListKeyEqual( self.issue.labels, lambda l: l.name, [ "Bug", "Project management", "Question" ] ) - self.assertEqual( self.issue.milestone.title, "Version 0.4" ) - self.assertEqual( self.issue.number, 28 ) - self.assertEqual( self.issue.pull_request, {u'diff_url': None, u'patch_url': None, u'html_url': None} ) ### @todo - self.assertEqual( self.issue.state, "closed" ) - self.assertEqual( self.issue.title, "Issue created by PyGithub" ) - self.assertEqual( self.issue.updated_at, "2012-05-26T14:59:33Z" ) - self.assertEqual( self.issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/28" ) - self.assertEqual( self.issue.user.login, "jacquev6" ) - - def testEditWithoutParameters( self ): - self.issue.edit() - - def testEditWithAllParameters( self ): - ### @todo Variadic argument for labels? - ### @todo NamedUser instead of string for assignee - self.issue.edit( "Title edited by PyGithub", "Body edited by PyGithub", "jacquev6", "open", 2, [ "Bug" ] ) - self.assertEqual( self.issue.assignee.login, "jacquev6" ) - self.assertEqual( self.issue.body, "Body edited by PyGithub" ) - self.assertEqual( self.issue.state, "open" ) - self.assertEqual( self.issue.title, "Title edited by PyGithub" ) - self.assertEqual( len( self.issue.labels ), 1 ) - self.assertEqual( self.issue.labels[ 0 ].name, "Bug" ) - - def testCreateComment( self ): - comment = self.issue.create_comment( "Comment created by PyGithub" ) - self.assertEqual( comment.id, 5808311 ) - - def testGetComments( self ): - self.assertListKeyEqual( self.issue.get_comments(), lambda c: c.user.login, [ "jacquev6", "roskakori" ] ) - - def testGetEvents( self ): - self.assertListKeyEqual( self.issue.get_events(), lambda e: e.id, [ 15819975, 15820048 ] ) - - def testGetLabels( self ): - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) - - def testAddAndRemoveLabels( self ): - bug = self.repo.get_label( "Bug" ) - question = self.repo.get_label( "Question" ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) - self.issue.remove_from_labels( bug ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Project management", "Question" ] ) - self.issue.remove_from_labels( question ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Project management" ] ) - self.issue.add_to_labels( bug, question ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) - - def testDeleteAndSetLabels( self ): - bug = self.repo.get_label( "Bug" ) - question = self.repo.get_label( "Question" ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) - self.issue.delete_labels() - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [] ) - self.issue.set_labels( bug, question ) - self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Question" ] ) +import Framework + +class Issue( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.repo = self.g.get_user().get_repo( "PyGithub" ) + self.issue = self.repo.get_issue( 28 ) + + def testAttributes( self ): + self.assertEqual( self.issue.assignee.login, "jacquev6" ) + self.assertEqual( self.issue.body, "Body edited by PyGithub" ) + self.assertEqual( self.issue.closed_at, "2012-05-26T14:59:33Z" ) + self.assertEqual( self.issue.closed_by.login, "jacquev6" ) + self.assertEqual( self.issue.comments, 0 ) + self.assertEqual( self.issue.created_at, "2012-05-19T10:38:23Z" ) + self.assertEqual( self.issue.html_url, "https://github.com/jacquev6/PyGithub/issues/28" ) + self.assertEqual( self.issue.id, 4653757 ) + self.assertListKeyEqual( self.issue.labels, lambda l: l.name, [ "Bug", "Project management", "Question" ] ) + self.assertEqual( self.issue.milestone.title, "Version 0.4" ) + self.assertEqual( self.issue.number, 28 ) + self.assertEqual( self.issue.pull_request, {u'diff_url': None, u'patch_url': None, u'html_url': None} ) ### @todo + self.assertEqual( self.issue.state, "closed" ) + self.assertEqual( self.issue.title, "Issue created by PyGithub" ) + self.assertEqual( self.issue.updated_at, "2012-05-26T14:59:33Z" ) + self.assertEqual( self.issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/28" ) + self.assertEqual( self.issue.user.login, "jacquev6" ) + + def testEditWithoutParameters( self ): + self.issue.edit() + + def testEditWithAllParameters( self ): + ### @todo Variadic argument for labels? + ### @todo NamedUser instead of string for assignee + self.issue.edit( "Title edited by PyGithub", "Body edited by PyGithub", "jacquev6", "open", 2, [ "Bug" ] ) + self.assertEqual( self.issue.assignee.login, "jacquev6" ) + self.assertEqual( self.issue.body, "Body edited by PyGithub" ) + self.assertEqual( self.issue.state, "open" ) + self.assertEqual( self.issue.title, "Title edited by PyGithub" ) + self.assertEqual( len( self.issue.labels ), 1 ) + self.assertEqual( self.issue.labels[ 0 ].name, "Bug" ) + + def testCreateComment( self ): + comment = self.issue.create_comment( "Comment created by PyGithub" ) + self.assertEqual( comment.id, 5808311 ) + + def testGetComments( self ): + self.assertListKeyEqual( self.issue.get_comments(), lambda c: c.user.login, [ "jacquev6", "roskakori" ] ) + + def testGetEvents( self ): + self.assertListKeyEqual( self.issue.get_events(), lambda e: e.id, [ 15819975, 15820048 ] ) + + def testGetLabels( self ): + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) + + def testAddAndRemoveLabels( self ): + bug = self.repo.get_label( "Bug" ) + question = self.repo.get_label( "Question" ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) + self.issue.remove_from_labels( bug ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Project management", "Question" ] ) + self.issue.remove_from_labels( question ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Project management" ] ) + self.issue.add_to_labels( bug, question ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) + + def testDeleteAndSetLabels( self ): + bug = self.repo.get_label( "Bug" ) + question = self.repo.get_label( "Question" ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Project management", "Question" ] ) + self.issue.delete_labels() + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [] ) + self.issue.set_labels( bug, question ) + self.assertListKeyEqual( self.issue.get_labels(), lambda l: l.name, [ "Bug", "Question" ] ) diff --git a/test/IssueComment.py b/test/IssueComment.py index 8b42b204..62874744 100644 --- a/test/IssueComment.py +++ b/test/IssueComment.py @@ -1,22 +1,22 @@ -import Framework - -class IssueComment( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.comment = self.g.get_user().get_repo( "PyGithub" ).get_issue( 28 ).get_comment( 5808311 ) - - def testAttributes( self ): - self.assertEqual( self.comment.body, "Comment created by PyGithub" ) - self.assertEqual( self.comment.created_at, "2012-05-20T11:46:42Z" ) - self.assertEqual( self.comment.id, 5808311 ) - self.assertEqual( self.comment.updated_at, "2012-05-20T11:46:42Z" ) - self.assertEqual( self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311" ) - self.assertEqual( self.comment.user.login, "jacquev6" ) - - def testEdit( self ): - self.comment.edit( "Comment edited by PyGithub" ) - self.assertEqual( self.comment.body, "Comment edited by PyGithub" ) - self.assertEqual( self.comment.updated_at, "2012-05-20T11:53:59Z" ) - - def testDelete( self ): - self.comment.delete() +import Framework + +class IssueComment( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.comment = self.g.get_user().get_repo( "PyGithub" ).get_issue( 28 ).get_comment( 5808311 ) + + def testAttributes( self ): + self.assertEqual( self.comment.body, "Comment created by PyGithub" ) + self.assertEqual( self.comment.created_at, "2012-05-20T11:46:42Z" ) + self.assertEqual( self.comment.id, 5808311 ) + self.assertEqual( self.comment.updated_at, "2012-05-20T11:46:42Z" ) + self.assertEqual( self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311" ) + self.assertEqual( self.comment.user.login, "jacquev6" ) + + def testEdit( self ): + self.comment.edit( "Comment edited by PyGithub" ) + self.assertEqual( self.comment.body, "Comment edited by PyGithub" ) + self.assertEqual( self.comment.updated_at, "2012-05-20T11:53:59Z" ) + + def testDelete( self ): + self.comment.delete() diff --git a/test/IssueEvent.py b/test/IssueEvent.py index 77fa5148..07514c86 100644 --- a/test/IssueEvent.py +++ b/test/IssueEvent.py @@ -1,15 +1,15 @@ -import Framework - -class IssueEvent( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.event = self.g.get_user().get_repo( "PyGithub" ).get_issues_event( 16348656 ) - - def testAttributes( self ): - self.assertEqual( self.event.actor.login, "jacquev6" ) - self.assertEqual( self.event.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433" ) - self.assertEqual( self.event.created_at, "2012-05-27T07:29:25Z" ) - self.assertEqual( self.event.event, "referenced" ) - self.assertEqual( self.event.id, 16348656 ) - self.assertEqual( self.event.issue.number, 30 ) - self.assertEqual( self.event.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/events/16348656" ) +import Framework + +class IssueEvent( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.event = self.g.get_user().get_repo( "PyGithub" ).get_issues_event( 16348656 ) + + def testAttributes( self ): + self.assertEqual( self.event.actor.login, "jacquev6" ) + self.assertEqual( self.event.commit_id, "ed866fc43833802ab553e5ff8581c81bb00dd433" ) + self.assertEqual( self.event.created_at, "2012-05-27T07:29:25Z" ) + self.assertEqual( self.event.event, "referenced" ) + self.assertEqual( self.event.id, 16348656 ) + self.assertEqual( self.event.issue.number, 30 ) + self.assertEqual( self.event.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/events/16348656" ) diff --git a/test/Label.py b/test/Label.py index 841b1550..61a4a4de 100644 --- a/test/Label.py +++ b/test/Label.py @@ -1,20 +1,20 @@ -import Framework - -class Label( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.label = self.g.get_user().get_repo( "PyGithub" ).get_label( "Bug" ) - - def testAttributes( self ): - self.assertEqual( self.label.color, "e10c02" ) - self.assertEqual( self.label.name, "Bug" ) - self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug" ) - - def testEdit( self ): - self.label.edit( "LabelEditedByPyGithub", "0000ff" ) - self.assertEqual( self.label.color, "0000ff" ) - self.assertEqual( self.label.name, "LabelEditedByPyGithub" ) - self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/LabelEditedByPyGithub" ) - - def testDelete( self ): - self.label.delete() +import Framework + +class Label( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.label = self.g.get_user().get_repo( "PyGithub" ).get_label( "Bug" ) + + def testAttributes( self ): + self.assertEqual( self.label.color, "e10c02" ) + self.assertEqual( self.label.name, "Bug" ) + self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug" ) + + def testEdit( self ): + self.label.edit( "LabelEditedByPyGithub", "0000ff" ) + self.assertEqual( self.label.color, "0000ff" ) + self.assertEqual( self.label.name, "LabelEditedByPyGithub" ) + self.assertEqual( self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/LabelEditedByPyGithub" ) + + def testDelete( self ): + self.label.delete() diff --git a/test/Milestone.py b/test/Milestone.py index da913306..2b7d16f4 100644 --- a/test/Milestone.py +++ b/test/Milestone.py @@ -1,36 +1,36 @@ -import Framework - -class Milestone( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.milestone = self.g.get_user().get_repo( "PyGithub" ).get_milestone( 1 ) - - def testAttributes( self ): - self.assertEqual( self.milestone.closed_issues, 2 ) - self.assertEqual( self.milestone.created_at, "2012-03-08T12:22:10Z" ) - self.assertEqual( self.milestone.description, "" ) - self.assertEqual( self.milestone.due_on, "2012-03-13T07:00:00Z" ) - self.assertEqual( self.milestone.id, 93546 ) - self.assertEqual( self.milestone.number, 1 ) - self.assertEqual( self.milestone.open_issues, 0 ) - self.assertEqual( self.milestone.state, "closed" ) - self.assertEqual( self.milestone.title, "Version 0.4" ) - self.assertEqual( self.milestone.url, "https://api.github.com/repos/jacquev6/PyGithub/milestones/1" ) - self.assertEqual( self.milestone.creator.login, "jacquev6" ) - - def testEditWithMinimalParameters( self ): - self.milestone.edit( "Title edited by PyGithub" ) - self.assertEqual( self.milestone.title, "Title edited by PyGithub" ) - - def testEditWithAllParameters( self ): - self.milestone.edit( "Title edited twice by PyGithub", "closed", "Description edited by PyGithub", due_on = "2012-06-16" ) - self.assertEqual( self.milestone.title, "Title edited twice by PyGithub" ) - self.assertEqual( self.milestone.state, "closed" ) - self.assertEqual( self.milestone.description, "Description edited by PyGithub" ) - self.assertEqual( self.milestone.due_on, "2012-06-16T07:00:00Z" ) - - def testGetLabels( self ): - self.assertListKeyEqual( self.milestone.get_labels(), lambda l: l.name, [ "Public interface", "Project management" ] ) - - def testDelete( self ): - self.milestone.delete() +import Framework + +class Milestone( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.milestone = self.g.get_user().get_repo( "PyGithub" ).get_milestone( 1 ) + + def testAttributes( self ): + self.assertEqual( self.milestone.closed_issues, 2 ) + self.assertEqual( self.milestone.created_at, "2012-03-08T12:22:10Z" ) + self.assertEqual( self.milestone.description, "" ) + self.assertEqual( self.milestone.due_on, "2012-03-13T07:00:00Z" ) + self.assertEqual( self.milestone.id, 93546 ) + self.assertEqual( self.milestone.number, 1 ) + self.assertEqual( self.milestone.open_issues, 0 ) + self.assertEqual( self.milestone.state, "closed" ) + self.assertEqual( self.milestone.title, "Version 0.4" ) + self.assertEqual( self.milestone.url, "https://api.github.com/repos/jacquev6/PyGithub/milestones/1" ) + self.assertEqual( self.milestone.creator.login, "jacquev6" ) + + def testEditWithMinimalParameters( self ): + self.milestone.edit( "Title edited by PyGithub" ) + self.assertEqual( self.milestone.title, "Title edited by PyGithub" ) + + def testEditWithAllParameters( self ): + self.milestone.edit( "Title edited twice by PyGithub", "closed", "Description edited by PyGithub", due_on = "2012-06-16" ) + self.assertEqual( self.milestone.title, "Title edited twice by PyGithub" ) + self.assertEqual( self.milestone.state, "closed" ) + self.assertEqual( self.milestone.description, "Description edited by PyGithub" ) + self.assertEqual( self.milestone.due_on, "2012-06-16T07:00:00Z" ) + + def testGetLabels( self ): + self.assertListKeyEqual( self.milestone.get_labels(), lambda l: l.name, [ "Public interface", "Project management" ] ) + + def testDelete( self ): + self.milestone.delete() diff --git a/test/PullRequest.py b/test/PullRequest.py index 67651c0a..4b5b5f37 100644 --- a/test/PullRequest.py +++ b/test/PullRequest.py @@ -1,66 +1,66 @@ -import Framework - -class PullRequest( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.pull = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ) - - def testAttributes( self ): - self.assertEqual( self.pull.additions, 511 ) - self.assertEqual( self.pull.base, {u'repo': {u'has_wiki': False, u'mirror_url': None, u'updated_at': u'2012-05-27T10:29:10Z', u'private': False, u'full_name': u'jacquev6/PyGithub', u'owner': {u'url': u'https://api.github.com/users/jacquev6', u'login': u'jacquev6', u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png', u'id': 327146, u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225'}, u'id': 3544490, u'size': 188, u'clone_url': u'https://github.com/jacquev6/PyGithub.git', u'forks': 3, u'homepage': u'http://vincent-jacques.net/PyGithub', u'fork': False, u'description': u'Python library implementing the full Github API v3', u'has_downloads': True, u'html_url': u'https://github.com/jacquev6/PyGithub', u'git_url': u'git://github.com/jacquev6/PyGithub.git', u'svn_url': u'https://github.com/jacquev6/PyGithub', u'ssh_url': u'git@github.com:jacquev6/PyGithub.git', u'has_issues': True, u'watchers': 15, u'name': u'PyGithub', u'language': u'Python', u'url': u'https://api.github.com/repos/jacquev6/PyGithub', u'created_at': u'2012-02-25T12:53:47Z', u'pushed_at': u'2012-05-27T10:29:09Z', u'open_issues': 16}, u'sha': u'ed866fc43833802ab553e5ff8581c81bb00dd433', u'ref': u'topic/RewriteWithGeneratedCode', u'user': {u'url': u'https://api.github.com/users/jacquev6', u'login': u'jacquev6', u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png', u'id': 327146, u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225'}, u'label': u'jacquev6:topic/RewriteWithGeneratedCode'} ) ### @todo - self.assertEqual( self.pull.body, "Body edited by PyGithub" ) - self.assertEqual( self.pull.changed_files, 45 ) - self.assertEqual( self.pull.closed_at, "2012-05-27T10:29:07Z" ) - self.assertEqual( self.pull.comments, 0 ) - self.assertEqual( self.pull.commits, 3 ) - self.assertEqual( self.pull.created_at, "2012-05-27T09:25:36Z" ) - self.assertEqual( self.pull.deletions, 384 ) - self.assertEqual( self.pull.diff_url, "https://github.com/jacquev6/PyGithub/pull/31.diff" ) - self.assertEqual( self.pull.head, {u'repo': {u'has_wiki': False, u'mirror_url': None, u'updated_at': u'2012-05-27T09:09:17Z', u'private': False, u'full_name': u'BeaverSoftware/PyGithub', u'owner': {u'url': u'https://api.github.com/users/BeaverSoftware', u'login': u'BeaverSoftware', u'avatar_url': u'https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png', u'id': 1424031, u'gravatar_id': u'd563e337cac2fdc644e2aaaad1e23266'}, u'id': 4460787, u'size': 176, u'clone_url': u'https://github.com/BeaverSoftware/PyGithub.git', u'forks': 0, u'homepage': u'http://vincent-jacques.net/PyGithub', u'fork': True, u'description': u'Python library implementing the full Github API v3', u'has_downloads': True, u'html_url': u'https://github.com/BeaverSoftware/PyGithub', u'git_url': u'git://github.com/BeaverSoftware/PyGithub.git', u'svn_url': u'https://github.com/BeaverSoftware/PyGithub', u'ssh_url': u'git@github.com:BeaverSoftware/PyGithub.git', u'has_issues': False, u'watchers': 1, u'name': u'PyGithub', u'language': u'Python', u'url': u'https://api.github.com/repos/BeaverSoftware/PyGithub', u'created_at': u'2012-05-27T08:50:04Z', u'pushed_at': u'2012-05-27T09:09:17Z', u'open_issues': 0}, u'sha': u'8a4f306d4b223682dd19410d4a9150636ebe4206', u'ref': u'master', u'user': {u'url': u'https://api.github.com/users/BeaverSoftware', u'login': u'BeaverSoftware', u'avatar_url': u'https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png', u'id': 1424031, u'gravatar_id': u'd563e337cac2fdc644e2aaaad1e23266'}, u'label': u'BeaverSoftware:master'} ) ### @todo - self.assertEqual( self.pull.html_url, "https://github.com/jacquev6/PyGithub/pull/31" ) - self.assertEqual( self.pull.id, 1436215 ) - self.assertEqual( self.pull.issue_url, "https://github.com/jacquev6/PyGithub/issues/31" ) - self.assertEqual( self.pull.mergeable, None ) - self.assertEqual( self.pull.merged, True ) - self.assertEqual( self.pull.merged_at, "2012-05-27T10:29:07Z" ) - self.assertEqual( self.pull.merged_by.login, "jacquev6" ) - self.assertEqual( self.pull.number, 31 ) - self.assertEqual( self.pull.patch_url, "https://github.com/jacquev6/PyGithub/pull/31.patch" ) - self.assertEqual( self.pull.review_comments, 1 ) - self.assertEqual( self.pull.state, "closed" ) - self.assertEqual( self.pull.title, "Title edited by PyGithub" ) - self.assertEqual( self.pull.updated_at, "2012-05-27T10:29:07Z" ) - self.assertEqual( self.pull.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/31" ) - self.assertEqual( self.pull.user.login, "jacquev6" ) - - def testCreateComment( self ): - ### @todo in_reply_to - comment = self.pull.create_comment( "Comment created by PyGithub", "8a4f306d4b223682dd19410d4a9150636ebe4206", "src/github/Issue.py", 5 ) - self.assertEqual( comment.id, 886298 ) - - def testGetComments( self ): - self.assertListKeyEqual( self.pull.get_comments(), lambda c: c.id, [ 886298 ] ) - - def testEditWithoutArguments( self ): - self.pull.edit() - - def testEditWithAllArguments( self ): - self.pull.edit( "Title edited by PyGithub", "Body edited by PyGithub", "open" ) - self.assertEqual( self.pull.title, "Title edited by PyGithub" ) - self.assertEqual( self.pull.body, "Body edited by PyGithub" ) - self.assertEqual( self.pull.state, "open" ) - - def testGetCommits( self ): - self.assertListKeyEqual( self.pull.get_commits(), lambda c: c.sha, [ "4aadfff21cdd2d2566b0e4bd7309c233b5f4ae23", "93dcae5cf207de376c91d0599226e7c7563e1d16", "8a4f306d4b223682dd19410d4a9150636ebe4206" ] ) - - def testGetFiles( self ): - self.assertListKeyEqual( self.pull.get_files(), lambda f: f.filename, [ "codegen/templates/GithubObject.py", "src/github/AuthenticatedUser.py", "src/github/Authorization.py", "src/github/Branch.py", "src/github/Commit.py", "src/github/CommitComment.py", "src/github/CommitFile.py", "src/github/CommitStats.py", "src/github/Download.py", "src/github/Event.py", "src/github/Gist.py", "src/github/GistComment.py", "src/github/GistHistoryState.py", "src/github/GitAuthor.py", "src/github/GitBlob.py", "src/github/GitCommit.py", "src/github/GitObject.py", "src/github/GitRef.py", "src/github/GitTag.py", "src/github/GitTree.py", "src/github/GitTreeElement.py", "src/github/Hook.py", "src/github/Issue.py", "src/github/IssueComment.py", "src/github/IssueEvent.py", "src/github/Label.py", "src/github/Milestone.py", "src/github/NamedUser.py", "src/github/Organization.py", "src/github/Permissions.py", "src/github/Plan.py", "src/github/PullRequest.py", "src/github/PullRequestComment.py", "src/github/PullRequestFile.py", "src/github/Repository.py", "src/github/RepositoryKey.py", "src/github/Tag.py", "src/github/Team.py", "src/github/UserKey.py", "test/Issue.py", "test/IssueEvent.py", "test/ReplayData/Issue.testAddAndRemoveLabels.txt", "test/ReplayData/Issue.testDeleteAndSetLabels.txt", "test/ReplayData/Issue.testGetLabels.txt", "test/ReplayData/IssueEvent.setUp.txt" ] ) - - def testMerge( self ): - self.assertFalse( self.pull.is_merged() ) - status = self.pull.merge() ### @todo message - ### @todo PullRequestMergeStatus - # self.assertEqual( status.sha, "" ) - # self.assertEqual( status.merged, True ) - # self.assertEqual( status.message, "" ) - self.assertTrue( self.pull.is_merged() ) +import Framework + +class PullRequest( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.pull = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ) + + def testAttributes( self ): + self.assertEqual( self.pull.additions, 511 ) + self.assertEqual( self.pull.base, {u'repo': {u'has_wiki': False, u'mirror_url': None, u'updated_at': u'2012-05-27T10:29:10Z', u'private': False, u'full_name': u'jacquev6/PyGithub', u'owner': {u'url': u'https://api.github.com/users/jacquev6', u'login': u'jacquev6', u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png', u'id': 327146, u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225'}, u'id': 3544490, u'size': 188, u'clone_url': u'https://github.com/jacquev6/PyGithub.git', u'forks': 3, u'homepage': u'http://vincent-jacques.net/PyGithub', u'fork': False, u'description': u'Python library implementing the full Github API v3', u'has_downloads': True, u'html_url': u'https://github.com/jacquev6/PyGithub', u'git_url': u'git://github.com/jacquev6/PyGithub.git', u'svn_url': u'https://github.com/jacquev6/PyGithub', u'ssh_url': u'git@github.com:jacquev6/PyGithub.git', u'has_issues': True, u'watchers': 15, u'name': u'PyGithub', u'language': u'Python', u'url': u'https://api.github.com/repos/jacquev6/PyGithub', u'created_at': u'2012-02-25T12:53:47Z', u'pushed_at': u'2012-05-27T10:29:09Z', u'open_issues': 16}, u'sha': u'ed866fc43833802ab553e5ff8581c81bb00dd433', u'ref': u'topic/RewriteWithGeneratedCode', u'user': {u'url': u'https://api.github.com/users/jacquev6', u'login': u'jacquev6', u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png', u'id': 327146, u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225'}, u'label': u'jacquev6:topic/RewriteWithGeneratedCode'} ) ### @todo + self.assertEqual( self.pull.body, "Body edited by PyGithub" ) + self.assertEqual( self.pull.changed_files, 45 ) + self.assertEqual( self.pull.closed_at, "2012-05-27T10:29:07Z" ) + self.assertEqual( self.pull.comments, 0 ) + self.assertEqual( self.pull.commits, 3 ) + self.assertEqual( self.pull.created_at, "2012-05-27T09:25:36Z" ) + self.assertEqual( self.pull.deletions, 384 ) + self.assertEqual( self.pull.diff_url, "https://github.com/jacquev6/PyGithub/pull/31.diff" ) + self.assertEqual( self.pull.head, {u'repo': {u'has_wiki': False, u'mirror_url': None, u'updated_at': u'2012-05-27T09:09:17Z', u'private': False, u'full_name': u'BeaverSoftware/PyGithub', u'owner': {u'url': u'https://api.github.com/users/BeaverSoftware', u'login': u'BeaverSoftware', u'avatar_url': u'https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png', u'id': 1424031, u'gravatar_id': u'd563e337cac2fdc644e2aaaad1e23266'}, u'id': 4460787, u'size': 176, u'clone_url': u'https://github.com/BeaverSoftware/PyGithub.git', u'forks': 0, u'homepage': u'http://vincent-jacques.net/PyGithub', u'fork': True, u'description': u'Python library implementing the full Github API v3', u'has_downloads': True, u'html_url': u'https://github.com/BeaverSoftware/PyGithub', u'git_url': u'git://github.com/BeaverSoftware/PyGithub.git', u'svn_url': u'https://github.com/BeaverSoftware/PyGithub', u'ssh_url': u'git@github.com:BeaverSoftware/PyGithub.git', u'has_issues': False, u'watchers': 1, u'name': u'PyGithub', u'language': u'Python', u'url': u'https://api.github.com/repos/BeaverSoftware/PyGithub', u'created_at': u'2012-05-27T08:50:04Z', u'pushed_at': u'2012-05-27T09:09:17Z', u'open_issues': 0}, u'sha': u'8a4f306d4b223682dd19410d4a9150636ebe4206', u'ref': u'master', u'user': {u'url': u'https://api.github.com/users/BeaverSoftware', u'login': u'BeaverSoftware', u'avatar_url': u'https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png', u'id': 1424031, u'gravatar_id': u'd563e337cac2fdc644e2aaaad1e23266'}, u'label': u'BeaverSoftware:master'} ) ### @todo + self.assertEqual( self.pull.html_url, "https://github.com/jacquev6/PyGithub/pull/31" ) + self.assertEqual( self.pull.id, 1436215 ) + self.assertEqual( self.pull.issue_url, "https://github.com/jacquev6/PyGithub/issues/31" ) + self.assertEqual( self.pull.mergeable, None ) + self.assertEqual( self.pull.merged, True ) + self.assertEqual( self.pull.merged_at, "2012-05-27T10:29:07Z" ) + self.assertEqual( self.pull.merged_by.login, "jacquev6" ) + self.assertEqual( self.pull.number, 31 ) + self.assertEqual( self.pull.patch_url, "https://github.com/jacquev6/PyGithub/pull/31.patch" ) + self.assertEqual( self.pull.review_comments, 1 ) + self.assertEqual( self.pull.state, "closed" ) + self.assertEqual( self.pull.title, "Title edited by PyGithub" ) + self.assertEqual( self.pull.updated_at, "2012-05-27T10:29:07Z" ) + self.assertEqual( self.pull.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/31" ) + self.assertEqual( self.pull.user.login, "jacquev6" ) + + def testCreateComment( self ): + ### @todo in_reply_to + comment = self.pull.create_comment( "Comment created by PyGithub", "8a4f306d4b223682dd19410d4a9150636ebe4206", "src/github/Issue.py", 5 ) + self.assertEqual( comment.id, 886298 ) + + def testGetComments( self ): + self.assertListKeyEqual( self.pull.get_comments(), lambda c: c.id, [ 886298 ] ) + + def testEditWithoutArguments( self ): + self.pull.edit() + + def testEditWithAllArguments( self ): + self.pull.edit( "Title edited by PyGithub", "Body edited by PyGithub", "open" ) + self.assertEqual( self.pull.title, "Title edited by PyGithub" ) + self.assertEqual( self.pull.body, "Body edited by PyGithub" ) + self.assertEqual( self.pull.state, "open" ) + + def testGetCommits( self ): + self.assertListKeyEqual( self.pull.get_commits(), lambda c: c.sha, [ "4aadfff21cdd2d2566b0e4bd7309c233b5f4ae23", "93dcae5cf207de376c91d0599226e7c7563e1d16", "8a4f306d4b223682dd19410d4a9150636ebe4206" ] ) + + def testGetFiles( self ): + self.assertListKeyEqual( self.pull.get_files(), lambda f: f.filename, [ "codegen/templates/GithubObject.py", "src/github/AuthenticatedUser.py", "src/github/Authorization.py", "src/github/Branch.py", "src/github/Commit.py", "src/github/CommitComment.py", "src/github/CommitFile.py", "src/github/CommitStats.py", "src/github/Download.py", "src/github/Event.py", "src/github/Gist.py", "src/github/GistComment.py", "src/github/GistHistoryState.py", "src/github/GitAuthor.py", "src/github/GitBlob.py", "src/github/GitCommit.py", "src/github/GitObject.py", "src/github/GitRef.py", "src/github/GitTag.py", "src/github/GitTree.py", "src/github/GitTreeElement.py", "src/github/Hook.py", "src/github/Issue.py", "src/github/IssueComment.py", "src/github/IssueEvent.py", "src/github/Label.py", "src/github/Milestone.py", "src/github/NamedUser.py", "src/github/Organization.py", "src/github/Permissions.py", "src/github/Plan.py", "src/github/PullRequest.py", "src/github/PullRequestComment.py", "src/github/PullRequestFile.py", "src/github/Repository.py", "src/github/RepositoryKey.py", "src/github/Tag.py", "src/github/Team.py", "src/github/UserKey.py", "test/Issue.py", "test/IssueEvent.py", "test/ReplayData/Issue.testAddAndRemoveLabels.txt", "test/ReplayData/Issue.testDeleteAndSetLabels.txt", "test/ReplayData/Issue.testGetLabels.txt", "test/ReplayData/IssueEvent.setUp.txt" ] ) + + def testMerge( self ): + self.assertFalse( self.pull.is_merged() ) + status = self.pull.merge() ### @todo message + ### @todo PullRequestMergeStatus + # self.assertEqual( status.sha, "" ) + # self.assertEqual( status.merged, True ) + # self.assertEqual( status.message, "" ) + self.assertTrue( self.pull.is_merged() ) diff --git a/test/PullRequestComment.py b/test/PullRequestComment.py index 16f817fd..3a5abf6a 100644 --- a/test/PullRequestComment.py +++ b/test/PullRequestComment.py @@ -1,26 +1,26 @@ -import Framework - -class PullRequestComment( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.comment = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ).get_comment( 886298 ) - - def testAttributes( self ): - self.assertEqual( self.comment.body, "Comment created by PyGithub" ) - self.assertEqual( self.comment.commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) - self.assertEqual( self.comment.created_at, "2012-05-27T09:40:12Z" ) - self.assertEqual( self.comment.id, 886298 ) - self.assertEqual( self.comment.original_commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) - self.assertEqual( self.comment.original_position, 5 ) - self.assertEqual( self.comment.path, "src/github/Issue.py" ) - self.assertEqual( self.comment.position, 5 ) - self.assertEqual( self.comment.updated_at, "2012-05-27T09:40:12Z" ) - self.assertEqual( self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298" ) - self.assertEqual( self.comment.user.login, "jacquev6" ) - - def testEdit( self ): - self.comment.edit( "Comment edited by PyGithub" ) - self.assertEqual( self.comment.body, "Comment edited by PyGithub" ) - - def testDelete( self ): # Test PullRequest.get_comments before - self.comment.delete() +import Framework + +class PullRequestComment( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.comment = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ).get_comment( 886298 ) + + def testAttributes( self ): + self.assertEqual( self.comment.body, "Comment created by PyGithub" ) + self.assertEqual( self.comment.commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) + self.assertEqual( self.comment.created_at, "2012-05-27T09:40:12Z" ) + self.assertEqual( self.comment.id, 886298 ) + self.assertEqual( self.comment.original_commit_id, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) + self.assertEqual( self.comment.original_position, 5 ) + self.assertEqual( self.comment.path, "src/github/Issue.py" ) + self.assertEqual( self.comment.position, 5 ) + self.assertEqual( self.comment.updated_at, "2012-05-27T09:40:12Z" ) + self.assertEqual( self.comment.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/886298" ) + self.assertEqual( self.comment.user.login, "jacquev6" ) + + def testEdit( self ): + self.comment.edit( "Comment edited by PyGithub" ) + self.assertEqual( self.comment.body, "Comment edited by PyGithub" ) + + def testDelete( self ): # Test PullRequest.get_comments before + self.comment.delete() diff --git a/test/PullRequestFile.py b/test/PullRequestFile.py index ca1258ad..eaf201a0 100644 --- a/test/PullRequestFile.py +++ b/test/PullRequestFile.py @@ -1,17 +1,17 @@ -import Framework - -class PullRequestFile( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.file = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ).get_files()[ 0 ] - - def testAttributes( self ): - self.assertEqual( self.file.additions, 1 ) - self.assertEqual( self.file.blob_url, "https://github.com/jacquev6/PyGithub/blob/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py" ) - self.assertEqual( self.file.changes, 2 ) - self.assertEqual( self.file.deletions, 1 ) - self.assertEqual( self.file.filename, "codegen/templates/GithubObject.py" ) - self.assertEqual( self.file.patch, '@@ -70,7 +70,7 @@ def __useAttributes( self, attributes ):\n \n # @todo No need to check if attribute is in attributes when attribute is mandatory\n {% for attribute in class.attributes|dictsort:"name" %}\n- if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None:\n+ if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: # pragma no branch\n \n {% if attribute.type.cardinality == "scalar" %}\n {% if attribute.type.simple %}' ) - self.assertEqual( self.file.raw_url, "https://github.com/jacquev6/PyGithub/raw/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py" ) - self.assertEqual( self.file.sha, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) - self.assertEqual( self.file.status, "modified" ) +import Framework + +class PullRequestFile( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.file = self.g.get_user().get_repo( "PyGithub" ).get_pull( 31 ).get_files()[ 0 ] + + def testAttributes( self ): + self.assertEqual( self.file.additions, 1 ) + self.assertEqual( self.file.blob_url, "https://github.com/jacquev6/PyGithub/blob/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py" ) + self.assertEqual( self.file.changes, 2 ) + self.assertEqual( self.file.deletions, 1 ) + self.assertEqual( self.file.filename, "codegen/templates/GithubObject.py" ) + self.assertEqual( self.file.patch, '@@ -70,7 +70,7 @@ def __useAttributes( self, attributes ):\n \n # @todo No need to check if attribute is in attributes when attribute is mandatory\n {% for attribute in class.attributes|dictsort:"name" %}\n- if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None:\n+ if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: # pragma no branch\n \n {% if attribute.type.cardinality == "scalar" %}\n {% if attribute.type.simple %}' ) + self.assertEqual( self.file.raw_url, "https://github.com/jacquev6/PyGithub/raw/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py" ) + self.assertEqual( self.file.sha, "8a4f306d4b223682dd19410d4a9150636ebe4206" ) + self.assertEqual( self.file.status, "modified" ) diff --git a/test/ReplayData/CommitComment.setUp.txt b/test/ReplayData/CommitComment.setUp.txt index 28c3720a..e933d664 100644 --- a/test/ReplayData/CommitComment.setUp.txt +++ b/test/ReplayData/CommitComment.setUp.txt @@ -1,15 +1,15 @@ -GET /user {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4967'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"27524c635501121933f4f78c95b1945a"'), ('date', 'Fri, 18 May 2012 20:12:19 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"owned_private_repos":5,"collaborators":0,"type":"User","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","public_gists":1,"company":"Criteo","bio":"","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","private_gists":5,"plan":{"collaborators":1,"private_repos":5,"name":"micro","space":614400},"public_repos":11,"followers":13,"login":"jacquev6","blog":"http://vincent-jacques.net","email":"vincent@vincent-jacques.net","disk_usage":16852,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","total_private_repos":5,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24} - -GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c5eec74d4b76b80283636a8efe1a132c"'), ('date', 'Fri, 18 May 2012 20:12:20 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"svn_url":"https://github.com/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"updated_at":"2012-05-18T05:29:54Z","forks":2,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","open_issues":17,"fork":false,"ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-18T05:18:16Z","size":304,"private":false,"has_downloads":true,"watchers":13,"html_url":"https://github.com/jacquev6/PyGithub","owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","permissions":{"pull":true,"admin":true,"push":true},"mirror_url":null,"language":"Python","description":"Python library implementing the full Github API v3","created_at":"2012-02-25T12:53:47Z","id":3544490} - -GET /repos/jacquev6/PyGithub/comments/1361949 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('content-length', '714'), ('x-ratelimit-remaining', '4979'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eebb2ebe0274fc6672c9e7bad74e5f39"'), ('date', 'Tue, 22 May 2012 18:43:13 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/comments/1361949","path":null,"body":"Comment created by PyGithub","html_url":"https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949","created_at":"2012-05-22T18:40:18Z","commit_id":"6945921c529be14c3a8f566dd1e483674516d46d","position":null,"updated_at":"2012-05-22T18:40:18Z","id":1361949,"line":null,"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}} - +GET /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4967'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"27524c635501121933f4f78c95b1945a"'), ('date', 'Fri, 18 May 2012 20:12:19 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"owned_private_repos":5,"collaborators":0,"type":"User","hireable":false,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","public_gists":1,"company":"Criteo","bio":"","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","private_gists":5,"plan":{"collaborators":1,"private_repos":5,"name":"micro","space":614400},"public_repos":11,"followers":13,"login":"jacquev6","blog":"http://vincent-jacques.net","email":"vincent@vincent-jacques.net","disk_usage":16852,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","total_private_repos":5,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24} + +GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4966'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c5eec74d4b76b80283636a8efe1a132c"'), ('date', 'Fri, 18 May 2012 20:12:20 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"svn_url":"https://github.com/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"updated_at":"2012-05-18T05:29:54Z","forks":2,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","open_issues":17,"fork":false,"ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-18T05:18:16Z","size":304,"private":false,"has_downloads":true,"watchers":13,"html_url":"https://github.com/jacquev6/PyGithub","owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","permissions":{"pull":true,"admin":true,"push":true},"mirror_url":null,"language":"Python","description":"Python library implementing the full Github API v3","created_at":"2012-02-25T12:53:47Z","id":3544490} + +GET /repos/jacquev6/PyGithub/comments/1361949 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('content-length', '714'), ('x-ratelimit-remaining', '4979'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eebb2ebe0274fc6672c9e7bad74e5f39"'), ('date', 'Tue, 22 May 2012 18:43:13 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/comments/1361949","path":null,"body":"Comment created by PyGithub","html_url":"https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949","created_at":"2012-05-22T18:40:18Z","commit_id":"6945921c529be14c3a8f566dd1e483674516d46d","position":null,"updated_at":"2012-05-22T18:40:18Z","id":1361949,"line":null,"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}} + diff --git a/test/ReplayData/GistComment.setUp.txt b/test/ReplayData/GistComment.setUp.txt index 4aecbc7f..55a41ea9 100644 --- a/test/ReplayData/GistComment.setUp.txt +++ b/test/ReplayData/GistComment.setUp.txt @@ -1,10 +1,10 @@ -GET /gists/2729810 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4970'), ('content-length', '3280'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b01fb6ac81527f99db9f6f586b048ee3"'), ('date', 'Sat, 19 May 2012 06:58:15 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-02-29T16:47:12Z","forks":[],"url":"https://api.github.com/gists/2729810","comments":0,"public":true,"git_pull_url":"git://gist.github.com/2729810.git","files":{"fail_github.py":{"type":"application/python","raw_url":"https://gist.github.com/raw/2729810/2fb3aa84e0efa50dc0f4c18b5df5b7b9ab27076b/fail_github.py","size":1636,"filename":"fail_github.py","content":"import httplib\nimport base64\nimport json\n\nlogin = \"\"\npassword = \"\"\norgName = \"\"\nrepoName = \"FailGithubApi\"\n\ndef doRequest( verb, url, input ):\n input = json.dumps( input )\n cnx = httplib.HTTPSConnection( \"api.github.com\", strict = True )\n cnx.request( verb, url, input, { \"Authorization\" : \"Basic \" + base64.b64encode( login + \":\" + password ).replace( '\\n', '' ) } )\n response = cnx.getresponse()\n status = response.status\n output = response.read()\n cnx.close()\n print verb, url, input, \"=>\", status, output\n print\n if status < 200 or status >= 300:\n exit( 1 )\n return json.loads( output )\n\n# Create a repo\ndoRequest( \"POST\", \"/user/repos\", { \"name\": repoName } )\n\n# Create a blob, a tree, a commit and the master branch\nb = doRequest(\n \"POST\", \"/repos/%s/%s/git/blobs\" % ( login, repoName ),\n { \"content\": \"Content of the blob\", \"encoding\": \"latin1\" }\n)\nt = doRequest(\n \"POST\", \"/repos/%s/%s/git/trees\" % ( login, repoName ),\n { \"tree\" : [ { \"path\": \"foo.bar\", \"type\": \"blob\", \"mode\": \"100644\", \"sha\": b[\"sha\"] } ] }\n)\nc = doRequest(\n \"POST\", \"/repos/%s/%s/git/commits\" % ( login, repoName ),\n { \"parents\": [], \"message\": \"Message of the commit\", \"tree\": t[\"sha\"] }\n)\ndoRequest(\n \"POST\", \"/repos/%s/%s/git/refs\" % ( login, repoName ),\n { \"ref\": \"refs/heads/master\", \"sha\": c[\"sha\"] }\n)\n\n# Fork the repo\ndoRequest( \"POST\", \"/repos/%s/%s/forks?org=%s\" % ( login, repoName, orgName ), None )\n\n# Create a new blob => BOOM error 500\ndoRequest(\n \"POST\", \"/repos/%s/%s/git/blobs\" % ( orgName, repoName ),\n { \"content\": \"Content of the new blob\", \"encoding\": \"latin1\" }\n)\n","language":"Python"}},"html_url":"https://gist.github.com/2729810","git_push_url":"git@gist.github.com:2729810.git","user":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"description":"How to error 500 Github API v3, as requested by Rick (GitHub Staff)","created_at":"2012-02-29T16:47:12Z","id":"2729810","history":[{"url":"https://api.github.com/gists/2729810/a40de483e42ba33bda308371c0ef8383db73be9e","change_status":{"deletions":0,"additions":52,"total":52},"committed_at":"2012-02-29T16:47:12Z","version":"a40de483e42ba33bda308371c0ef8383db73be9e","user":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146}}]} - -GET /gists/comments/323629 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('content-length', '479'), ('x-ratelimit-limit', '5000'), ('x-ratelimit-remaining', '4988'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('etag', '"c2581153865c9b18a576589587e1fb98"'), ('date', 'Sat, 19 May 2012 07:12:31 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/gists/comments/323629","body":"Comment created by PyGithub","created_at":"2012-05-19T07:07:57Z","updated_at":"2012-05-19T07:07:57Z","id":323629,"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","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146}} - +GET /gists/2729810 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4970'), ('content-length', '3280'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b01fb6ac81527f99db9f6f586b048ee3"'), ('date', 'Sat, 19 May 2012 06:58:15 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"updated_at":"2012-02-29T16:47:12Z","forks":[],"url":"https://api.github.com/gists/2729810","comments":0,"public":true,"git_pull_url":"git://gist.github.com/2729810.git","files":{"fail_github.py":{"type":"application/python","raw_url":"https://gist.github.com/raw/2729810/2fb3aa84e0efa50dc0f4c18b5df5b7b9ab27076b/fail_github.py","size":1636,"filename":"fail_github.py","content":"import httplib\nimport base64\nimport json\n\nlogin = \"\"\npassword = \"\"\norgName = \"\"\nrepoName = \"FailGithubApi\"\n\ndef doRequest( verb, url, input ):\n input = json.dumps( input )\n cnx = httplib.HTTPSConnection( \"api.github.com\", strict = True )\n cnx.request( verb, url, input, { \"Authorization\" : \"Basic \" + base64.b64encode( login + \":\" + password ).replace( '\\n', '' ) } )\n response = cnx.getresponse()\n status = response.status\n output = response.read()\n cnx.close()\n print verb, url, input, \"=>\", status, output\n print\n if status < 200 or status >= 300:\n exit( 1 )\n return json.loads( output )\n\n# Create a repo\ndoRequest( \"POST\", \"/user/repos\", { \"name\": repoName } )\n\n# Create a blob, a tree, a commit and the master branch\nb = doRequest(\n \"POST\", \"/repos/%s/%s/git/blobs\" % ( login, repoName ),\n { \"content\": \"Content of the blob\", \"encoding\": \"latin1\" }\n)\nt = doRequest(\n \"POST\", \"/repos/%s/%s/git/trees\" % ( login, repoName ),\n { \"tree\" : [ { \"path\": \"foo.bar\", \"type\": \"blob\", \"mode\": \"100644\", \"sha\": b[\"sha\"] } ] }\n)\nc = doRequest(\n \"POST\", \"/repos/%s/%s/git/commits\" % ( login, repoName ),\n { \"parents\": [], \"message\": \"Message of the commit\", \"tree\": t[\"sha\"] }\n)\ndoRequest(\n \"POST\", \"/repos/%s/%s/git/refs\" % ( login, repoName ),\n { \"ref\": \"refs/heads/master\", \"sha\": c[\"sha\"] }\n)\n\n# Fork the repo\ndoRequest( \"POST\", \"/repos/%s/%s/forks?org=%s\" % ( login, repoName, orgName ), None )\n\n# Create a new blob => BOOM error 500\ndoRequest(\n \"POST\", \"/repos/%s/%s/git/blobs\" % ( orgName, repoName ),\n { \"content\": \"Content of the new blob\", \"encoding\": \"latin1\" }\n)\n","language":"Python"}},"html_url":"https://gist.github.com/2729810","git_push_url":"git@gist.github.com:2729810.git","user":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"description":"How to error 500 Github API v3, as requested by Rick (GitHub Staff)","created_at":"2012-02-29T16:47:12Z","id":"2729810","history":[{"url":"https://api.github.com/gists/2729810/a40de483e42ba33bda308371c0ef8383db73be9e","change_status":{"deletions":0,"additions":52,"total":52},"committed_at":"2012-02-29T16:47:12Z","version":"a40de483e42ba33bda308371c0ef8383db73be9e","user":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146}}]} + +GET /gists/comments/323629 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('content-length', '479'), ('x-ratelimit-limit', '5000'), ('x-ratelimit-remaining', '4988'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('etag', '"c2581153865c9b18a576589587e1fb98"'), ('date', 'Sat, 19 May 2012 07:12:31 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/gists/comments/323629","body":"Comment created by PyGithub","created_at":"2012-05-19T07:07:57Z","updated_at":"2012-05-19T07:07:57Z","id":323629,"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","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146}} + diff --git a/test/ReplayData/IssueComment.setUp.txt b/test/ReplayData/IssueComment.setUp.txt index 0ba301de..f1964e58 100644 --- a/test/ReplayData/IssueComment.setUp.txt +++ b/test/ReplayData/IssueComment.setUp.txt @@ -1,20 +1,20 @@ -GET /user {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4993'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"9459b6e1e4805aad5e10d13344d6ffbf"'), ('date', 'Sat, 26 May 2012 14:59:39 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"public_repos":11,"type":"User","hireable":false,"disk_usage":17080,"blog":"http://vincent-jacques.net","bio":"","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","total_private_repos":5,"plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"owned_private_repos":5,"company":"Criteo","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","collaborators":0,"public_gists":3,"email":"vincent@vincent-jacques.net","followers":13,"name":"Vincent Jacques","private_gists":5,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24,"html_url":"https://github.com/jacquev6"} - -GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('content-length', '1129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5dc65a168cf4d957347ea04221cd5102"'), ('date', 'Sat, 26 May 2012 14:59:39 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":13,"updated_at":"2012-05-26T11:25:48Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"private":false,"open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T11:25:48Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"git_url":"git://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"} - -GET /repos/jacquev6/PyGithub/issues/28 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '2258'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"071cb2b8bfef81f56b94d7d9397e6aa4"'), ('date', 'Sat, 26 May 2012 14:59:40 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-05-26T14:59:33Z","body":"Body edited by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/28","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/1","number":1,"title":"Version 0.4","due_on":"2012-03-13T07:00:00Z","open_issues":0,"created_at":"2012-03-08T12:22:10Z","state":"closed","description":"","id":93546,"closed_issues":3},"number":28,"closed_by":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"closed_at":"2012-05-26T14:59:33Z","title":"Issue created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-19T10:38:23Z","state":"closed","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4653757,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/28"} - -GET /repos/jacquev6/PyGithub/issues/comments/5808311 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '506'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4fa1a8e8e534bcc93123ea6ee8fd4284"'), ('date', 'Sun, 20 May 2012 11:50:56 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-05-20T11:46:42Z","body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311","created_at":"2012-05-20T11:46:42Z","user":{"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},"id":5808311} - +GET /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4993'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"9459b6e1e4805aad5e10d13344d6ffbf"'), ('date', 'Sat, 26 May 2012 14:59:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"public_repos":11,"type":"User","hireable":false,"disk_usage":17080,"blog":"http://vincent-jacques.net","bio":"","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","total_private_repos":5,"plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"owned_private_repos":5,"company":"Criteo","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","collaborators":0,"public_gists":3,"email":"vincent@vincent-jacques.net","followers":13,"name":"Vincent Jacques","private_gists":5,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24,"html_url":"https://github.com/jacquev6"} + +GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('content-length', '1129'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"5dc65a168cf4d957347ea04221cd5102"'), ('date', 'Sat, 26 May 2012 14:59:39 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":13,"updated_at":"2012-05-26T11:25:48Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"private":false,"open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T11:25:48Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"git_url":"git://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"} + +GET /repos/jacquev6/PyGithub/issues/28 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '2258'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"071cb2b8bfef81f56b94d7d9397e6aa4"'), ('date', 'Sat, 26 May 2012 14:59:40 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"updated_at":"2012-05-26T14:59:33Z","body":"Body edited by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/28","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/1","number":1,"title":"Version 0.4","due_on":"2012-03-13T07:00:00Z","open_issues":0,"created_at":"2012-03-08T12:22:10Z","state":"closed","description":"","id":93546,"closed_issues":3},"number":28,"closed_by":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"closed_at":"2012-05-26T14:59:33Z","title":"Issue created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Project+management","name":"Project management","color":"444444"},{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-19T10:38:23Z","state":"closed","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4653757,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/28"} + +GET /repos/jacquev6/PyGithub/issues/comments/5808311 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '506'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4fa1a8e8e534bcc93123ea6ee8fd4284"'), ('date', 'Sun, 20 May 2012 11:50:56 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"updated_at":"2012-05-20T11:46:42Z","body":"Comment created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311","created_at":"2012-05-20T11:46:42Z","user":{"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},"id":5808311} + diff --git a/test/ReplayData/Milestone.setUp.txt b/test/ReplayData/Milestone.setUp.txt index 6c2b9e47..73f18e2d 100644 --- a/test/ReplayData/Milestone.setUp.txt +++ b/test/ReplayData/Milestone.setUp.txt @@ -1,15 +1,15 @@ -GET /user {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"cafcc970ccfa36947999605caefbe3be"'), ('date', 'Fri, 11 May 2012 13:34:48 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"type":"User","bio":"","url":"https://api.github.com/users/jacquev6","blog":"http://vincent-jacques.net","total_private_repos":5,"disk_usage":16676,"plan":{"collaborators":1,"space":614400,"name":"micro","private_repos":5},"public_gists":1,"html_url":"https://github.com/jacquev6","owned_private_repos":5,"public_repos":11,"login":"jacquev6","private_gists":5,"collaborators":0,"email":"vincent@vincent-jacques.net","created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","followers":13,"following":24,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","hireable":false,"id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"} - -GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4998'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4a386c2ab2675e1e0addb729b4576ea9"'), ('date', 'Fri, 11 May 2012 13:34:49 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"updated_at":"2012-05-10T20:00:24Z","has_wiki":false,"has_issues":true,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","mirror_url":null,"forks":2,"html_url":"https://github.com/jacquev6/PyGithub","open_issues":15,"fork":false,"svn_url":"https://github.com/jacquev6/PyGithub","ssh_url":"git@github.com:jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","pushed_at":"2012-05-10T20:00:24Z","language":"Python","size":196,"private":false,"clone_url":"https://github.com/jacquev6/PyGithub.git","created_at":"2012-02-25T12:53:47Z","owner":{"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","login":"jacquev6","id":327146},"name":"PyGithub","has_downloads":true,"watchers":13,"description":"Python library implementing the full Github API v3","id":3544490,"permissions":{"admin":true,"pull":true,"push":true}} - -GET /repos/jacquev6/PyGithub/milestones/1 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '556'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"977ee5e1d9c368036c6121e01680ce45"'), ('date', 'Fri, 11 May 2012 13:34:49 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/1","number":1,"closed_issues":2,"title":"Version 0.4","due_on":"2012-03-13T07:00:00Z","created_at":"2012-03-08T12:22:10Z","state":"closed","creator":{"url":"https://api.github.com/users/jacquev6","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146},"description":"","open_issues":0,"id":93546} - +GET /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"cafcc970ccfa36947999605caefbe3be"'), ('date', 'Fri, 11 May 2012 13:34:48 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"type":"User","bio":"","url":"https://api.github.com/users/jacquev6","blog":"http://vincent-jacques.net","total_private_repos":5,"disk_usage":16676,"plan":{"collaborators":1,"space":614400,"name":"micro","private_repos":5},"public_gists":1,"html_url":"https://github.com/jacquev6","owned_private_repos":5,"public_repos":11,"login":"jacquev6","private_gists":5,"collaborators":0,"email":"vincent@vincent-jacques.net","created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","followers":13,"following":24,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","hireable":false,"id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"} + +GET /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4998'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"4a386c2ab2675e1e0addb729b4576ea9"'), ('date', 'Fri, 11 May 2012 13:34:49 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"updated_at":"2012-05-10T20:00:24Z","has_wiki":false,"has_issues":true,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","mirror_url":null,"forks":2,"html_url":"https://github.com/jacquev6/PyGithub","open_issues":15,"fork":false,"svn_url":"https://github.com/jacquev6/PyGithub","ssh_url":"git@github.com:jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","pushed_at":"2012-05-10T20:00:24Z","language":"Python","size":196,"private":false,"clone_url":"https://github.com/jacquev6/PyGithub.git","created_at":"2012-02-25T12:53:47Z","owner":{"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","login":"jacquev6","id":327146},"name":"PyGithub","has_downloads":true,"watchers":13,"description":"Python library implementing the full Github API v3","id":3544490,"permissions":{"admin":true,"pull":true,"push":true}} + +GET /repos/jacquev6/PyGithub/milestones/1 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '556'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"977ee5e1d9c368036c6121e01680ce45"'), ('date', 'Fri, 11 May 2012 13:34:49 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/1","number":1,"closed_issues":2,"title":"Version 0.4","due_on":"2012-03-13T07:00:00Z","created_at":"2012-03-08T12:22:10Z","state":"closed","creator":{"url":"https://api.github.com/users/jacquev6","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146},"description":"","open_issues":0,"id":93546} + diff --git a/test/ReplayData/NamedUser.testGetFollowers.txt b/test/ReplayData/NamedUser.testGetFollowers.txt index 735edd4b..66e90672 100644 --- a/test/ReplayData/NamedUser.testGetFollowers.txt +++ b/test/ReplayData/NamedUser.testGetFollowers.txt @@ -1,5 +1,5 @@ -GET /users/jacquev6/followers {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4958'), ('content-length', '3849'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f108ded43b2e23acc383f7eff74ee559"'), ('date', 'Sun, 20 May 2012 12:15:34 GMT'), ('content-type', 'application/json; charset=utf-8')] -[{"url":"https://api.github.com/users/jnorthrup","gravatar_id":"29222a2dca6dd4cd33790d72ff3f5346","login":"jnorthrup","avatar_url":"https://secure.gravatar.com/avatar/29222a2dca6dd4cd33790d72ff3f5346?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":73514},{"url":"https://api.github.com/users/brugidou","gravatar_id":"43485eeefd3da3c96a7ea0c7e6b839dc","login":"brugidou","avatar_url":"https://secure.gravatar.com/avatar/43485eeefd3da3c96a7ea0c7e6b839dc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":167633},{"url":"https://api.github.com/users/regisb","gravatar_id":"43d211a7021343f2be236d2b9855b734","login":"regisb","avatar_url":"https://secure.gravatar.com/avatar/43d211a7021343f2be236d2b9855b734?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":44319},{"url":"https://api.github.com/users/walidk","gravatar_id":"e251d20766937949a109603ca37bb3be","login":"walidk","avatar_url":"https://secure.gravatar.com/avatar/e251d20766937949a109603ca37bb3be?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":734669},{"url":"https://api.github.com/users/afzalkhan","gravatar_id":"8e85398b116be75d4baeeddfc9c3cce1","login":"afzalkhan","avatar_url":"https://secure.gravatar.com/avatar/8e85398b116be75d4baeeddfc9c3cce1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1003845},{"url":"https://api.github.com/users/sdanzan","gravatar_id":"4a1e187f4f22547534a56966f6d8f942","login":"sdanzan","avatar_url":"https://secure.gravatar.com/avatar/4a1e187f4f22547534a56966f6d8f942?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1094967},{"url":"https://api.github.com/users/vineus","gravatar_id":"2d0c93649b7572036335aed380e351e5","login":"vineus","avatar_url":"https://secure.gravatar.com/avatar/2d0c93649b7572036335aed380e351e5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":467126},{"url":"https://api.github.com/users/gturri","gravatar_id":"ba064e32f068e12bfc87d178179878a5","login":"gturri","avatar_url":"https://secure.gravatar.com/avatar/ba064e32f068e12bfc87d178179878a5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":308601},{"url":"https://api.github.com/users/fjardon","gravatar_id":"cb044bd9a9f6548b9a9bae44617c97c7","login":"fjardon","avatar_url":"https://secure.gravatar.com/avatar/cb044bd9a9f6548b9a9bae44617c97c7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":121402},{"url":"https://api.github.com/users/cjuniet","gravatar_id":"197eed5292fd11c0277335c3524ccfd5","login":"cjuniet","avatar_url":"https://secure.gravatar.com/avatar/197eed5292fd11c0277335c3524ccfd5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1233553},{"url":"https://api.github.com/users/jardon-u","gravatar_id":"1b4be24fa7e62eb508ca448da99e43d4","login":"jardon-u","avatar_url":"https://secure.gravatar.com/avatar/1b4be24fa7e62eb508ca448da99e43d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":994192},{"url":"https://api.github.com/users/kamaradclimber","gravatar_id":"0c43eba4a99f65e071e66e684cea8177","login":"kamaradclimber","avatar_url":"https://secure.gravatar.com/avatar/0c43eba4a99f65e071e66e684cea8177?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":503537},{"url":"https://api.github.com/users/L42y","gravatar_id":"4dc11d87759273f3466ab4f673bcecae","login":"L42y","avatar_url":"https://secure.gravatar.com/avatar/4dc11d87759273f3466ab4f673bcecae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":284820}] - +GET /users/jacquev6/followers {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4958'), ('content-length', '3849'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f108ded43b2e23acc383f7eff74ee559"'), ('date', 'Sun, 20 May 2012 12:15:34 GMT'), ('content-type', 'application/json; charset=utf-8')] +[{"url":"https://api.github.com/users/jnorthrup","gravatar_id":"29222a2dca6dd4cd33790d72ff3f5346","login":"jnorthrup","avatar_url":"https://secure.gravatar.com/avatar/29222a2dca6dd4cd33790d72ff3f5346?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":73514},{"url":"https://api.github.com/users/brugidou","gravatar_id":"43485eeefd3da3c96a7ea0c7e6b839dc","login":"brugidou","avatar_url":"https://secure.gravatar.com/avatar/43485eeefd3da3c96a7ea0c7e6b839dc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":167633},{"url":"https://api.github.com/users/regisb","gravatar_id":"43d211a7021343f2be236d2b9855b734","login":"regisb","avatar_url":"https://secure.gravatar.com/avatar/43d211a7021343f2be236d2b9855b734?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":44319},{"url":"https://api.github.com/users/walidk","gravatar_id":"e251d20766937949a109603ca37bb3be","login":"walidk","avatar_url":"https://secure.gravatar.com/avatar/e251d20766937949a109603ca37bb3be?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":734669},{"url":"https://api.github.com/users/afzalkhan","gravatar_id":"8e85398b116be75d4baeeddfc9c3cce1","login":"afzalkhan","avatar_url":"https://secure.gravatar.com/avatar/8e85398b116be75d4baeeddfc9c3cce1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1003845},{"url":"https://api.github.com/users/sdanzan","gravatar_id":"4a1e187f4f22547534a56966f6d8f942","login":"sdanzan","avatar_url":"https://secure.gravatar.com/avatar/4a1e187f4f22547534a56966f6d8f942?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1094967},{"url":"https://api.github.com/users/vineus","gravatar_id":"2d0c93649b7572036335aed380e351e5","login":"vineus","avatar_url":"https://secure.gravatar.com/avatar/2d0c93649b7572036335aed380e351e5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":467126},{"url":"https://api.github.com/users/gturri","gravatar_id":"ba064e32f068e12bfc87d178179878a5","login":"gturri","avatar_url":"https://secure.gravatar.com/avatar/ba064e32f068e12bfc87d178179878a5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":308601},{"url":"https://api.github.com/users/fjardon","gravatar_id":"cb044bd9a9f6548b9a9bae44617c97c7","login":"fjardon","avatar_url":"https://secure.gravatar.com/avatar/cb044bd9a9f6548b9a9bae44617c97c7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":121402},{"url":"https://api.github.com/users/cjuniet","gravatar_id":"197eed5292fd11c0277335c3524ccfd5","login":"cjuniet","avatar_url":"https://secure.gravatar.com/avatar/197eed5292fd11c0277335c3524ccfd5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":1233553},{"url":"https://api.github.com/users/jardon-u","gravatar_id":"1b4be24fa7e62eb508ca448da99e43d4","login":"jardon-u","avatar_url":"https://secure.gravatar.com/avatar/1b4be24fa7e62eb508ca448da99e43d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":994192},{"url":"https://api.github.com/users/kamaradclimber","gravatar_id":"0c43eba4a99f65e071e66e684cea8177","login":"kamaradclimber","avatar_url":"https://secure.gravatar.com/avatar/0c43eba4a99f65e071e66e684cea8177?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":503537},{"url":"https://api.github.com/users/L42y","gravatar_id":"4dc11d87759273f3466ab4f673bcecae","login":"L42y","avatar_url":"https://secure.gravatar.com/avatar/4dc11d87759273f3466ab4f673bcecae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":284820}] + diff --git a/test/ReplayData/Organization.setUp.txt b/test/ReplayData/Organization.setUp.txt index b1b7807d..03c374e4 100644 --- a/test/ReplayData/Organization.setUp.txt +++ b/test/ReplayData/Organization.setUp.txt @@ -1,5 +1,5 @@ -GET /orgs/BeaverSoftware {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '716'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"bd349122929faf5f9be3e53d9ad41d08"'), ('date', 'Fri, 11 May 2012 09:07:56 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"type":"Organization","url":"https://api.github.com/orgs/BeaverSoftware","billing_email":"BeaverSoftware@vincent-jacques.net","disk_usage":112,"plan":{"private_repos":0,"space":307200,"name":"free"},"html_url":"https://github.com/BeaverSoftware","blog":null,"login":"BeaverSoftware","public_gists":0,"email":null,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","total_private_repos":0,"private_gists":0,"collaborators":0,"created_at":"2012-02-09T19:20:12Z","company":null,"location":"Paris, France","followers":0,"following":0,"name":null,"owned_private_repos":0,"id":1424031,"public_repos":2} - +GET /orgs/BeaverSoftware {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '716'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"bd349122929faf5f9be3e53d9ad41d08"'), ('date', 'Fri, 11 May 2012 09:07:56 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"type":"Organization","url":"https://api.github.com/orgs/BeaverSoftware","billing_email":"BeaverSoftware@vincent-jacques.net","disk_usage":112,"plan":{"private_repos":0,"space":307200,"name":"free"},"html_url":"https://github.com/BeaverSoftware","blog":null,"login":"BeaverSoftware","public_gists":0,"email":null,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","total_private_repos":0,"private_gists":0,"collaborators":0,"created_at":"2012-02-09T19:20:12Z","company":null,"location":"Paris, France","followers":0,"following":0,"name":null,"owned_private_repos":0,"id":1424031,"public_repos":2} + diff --git a/test/ReplayData/Organization.testEditWithoutArguments.txt b/test/ReplayData/Organization.testEditWithoutArguments.txt index 1ad5ba1f..8f306156 100644 --- a/test/ReplayData/Organization.testEditWithoutArguments.txt +++ b/test/ReplayData/Organization.testEditWithoutArguments.txt @@ -1,5 +1,5 @@ -PATCH /orgs/BeaverSoftware {'Authorization': 'Basic login_and_password_removed'} {} -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('content-length', '716'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"a9ca2dd89f69da85bebd949477894af0"'), ('date', 'Fri, 11 May 2012 09:07:56 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"owned_private_repos":0,"private_gists":0,"type":"Organization","following":0,"company":null,"html_url":"https://github.com/BeaverSoftware","blog":null,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","followers":0,"url":"https://api.github.com/orgs/BeaverSoftware","public_repos":2,"login":"BeaverSoftware","collaborators":0,"email":null,"disk_usage":112,"plan":{"private_repos":0,"space":307200,"name":"free"},"created_at":"2012-02-09T19:20:12Z","name":null,"total_private_repos":0,"billing_email":"BeaverSoftware@vincent-jacques.net","public_gists":0,"id":1424031,"location":"Paris, France"} - +PATCH /orgs/BeaverSoftware {'Authorization': 'Basic login_and_password_removed'} {} +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('content-length', '716'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"a9ca2dd89f69da85bebd949477894af0"'), ('date', 'Fri, 11 May 2012 09:07:56 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"owned_private_repos":0,"private_gists":0,"type":"Organization","following":0,"company":null,"html_url":"https://github.com/BeaverSoftware","blog":null,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","followers":0,"url":"https://api.github.com/orgs/BeaverSoftware","public_repos":2,"login":"BeaverSoftware","collaborators":0,"email":null,"disk_usage":112,"plan":{"private_repos":0,"space":307200,"name":"free"},"created_at":"2012-02-09T19:20:12Z","name":null,"total_private_repos":0,"billing_email":"BeaverSoftware@vincent-jacques.net","public_gists":0,"id":1424031,"location":"Paris, France"} + diff --git a/test/ReplayData/RateLimiting.testRateLimiting.txt b/test/ReplayData/RateLimiting.testRateLimiting.txt index 4ed7f498..296a320f 100644 --- a/test/ReplayData/RateLimiting.testRateLimiting.txt +++ b/test/ReplayData/RateLimiting.testRateLimiting.txt @@ -1,5 +1,5 @@ -GET /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8cd01ddcd0adee5501abc607e6a640b0"'), ('date', 'Mon, 21 May 2012 11:08:21 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"total_private_repos":5,"public_gists":1,"type":"User","owned_private_repos":5,"private_gists":5,"company":"Criteo","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"followers":13,"blog":"http://vincent-jacques.net","collaborators":0,"login":"jacquev6","email":"vincent@vincent-jacques.net","disk_usage":16812,"public_repos":11,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","hireable":false,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24,"bio":""} - +GET /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8cd01ddcd0adee5501abc607e6a640b0"'), ('date', 'Mon, 21 May 2012 11:08:21 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"total_private_repos":5,"public_gists":1,"type":"User","owned_private_repos":5,"private_gists":5,"company":"Criteo","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"followers":13,"blog":"http://vincent-jacques.net","collaborators":0,"login":"jacquev6","email":"vincent@vincent-jacques.net","disk_usage":16812,"public_repos":11,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","hireable":false,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"following":24,"bio":""} + diff --git a/test/ReplayData/Repository.testCreateGitBlob.txt b/test/ReplayData/Repository.testCreateGitBlob.txt index f3289387..95630ea2 100644 --- a/test/ReplayData/Repository.testCreateGitBlob.txt +++ b/test/ReplayData/Repository.testCreateGitBlob.txt @@ -1,5 +1,5 @@ -POST /repos/jacquev6/PyGithub/git/blobs {'Authorization': 'Basic login_and_password_removed'} {"content": "Blob created by PyGithub", "encoding": "latin1"} -201 -[('status', '201 Created'), ('x-ratelimit-remaining', '4997'), ('content-length', '156'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f5cc2fa3ba4de95ac0eb8c2ca47350c0"'), ('date', 'Fri, 11 May 2012 11:43:09 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/git/blobs/5dd930f591cd5188e9ea7200e308ad355182a1d8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/blobs/5dd930f591cd5188e9ea7200e308ad355182a1d8","sha":"5dd930f591cd5188e9ea7200e308ad355182a1d8"} - +POST /repos/jacquev6/PyGithub/git/blobs {'Authorization': 'Basic login_and_password_removed'} {"content": "Blob created by PyGithub", "encoding": "latin1"} +201 +[('status', '201 Created'), ('x-ratelimit-remaining', '4997'), ('content-length', '156'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f5cc2fa3ba4de95ac0eb8c2ca47350c0"'), ('date', 'Fri, 11 May 2012 11:43:09 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/git/blobs/5dd930f591cd5188e9ea7200e308ad355182a1d8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/blobs/5dd930f591cd5188e9ea7200e308ad355182a1d8","sha":"5dd930f591cd5188e9ea7200e308ad355182a1d8"} + diff --git a/test/RepositoryKey.py b/test/RepositoryKey.py index 0ba0d5c2..5ae21670 100644 --- a/test/RepositoryKey.py +++ b/test/RepositoryKey.py @@ -1,24 +1,24 @@ -import Framework - -class RepositoryKey( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.key = self.g.get_user().get_repo( "PyGithub" ).get_key( 2626761 ) - - def testAttributes( self ): - self.assertEqual( self.key.id, 2626761 ) - self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==" ) - self.assertEqual( self.key.title, "Key added through PyGithub" ) - self.assertEqual( self.key.url, "https://api.github.com/user/keys/2626761" ) - self.assertEqual( self.key.verified, True ) - - def testEdit( self ): - self.key.edit( "Title edited by PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) - self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) - self.assertEqual( self.key.title, "Title edited by PyGithub" ) - - def testEditWithoutParameters( self ): - self.key.edit() - - def testDelete( self ): - self.key.delete() +import Framework + +class RepositoryKey( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.key = self.g.get_user().get_repo( "PyGithub" ).get_key( 2626761 ) + + def testAttributes( self ): + self.assertEqual( self.key.id, 2626761 ) + self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==" ) + self.assertEqual( self.key.title, "Key added through PyGithub" ) + self.assertEqual( self.key.url, "https://api.github.com/user/keys/2626761" ) + self.assertEqual( self.key.verified, True ) + + def testEdit( self ): + self.key.edit( "Title edited by PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) + self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) + self.assertEqual( self.key.title, "Title edited by PyGithub" ) + + def testEditWithoutParameters( self ): + self.key.edit() + + def testDelete( self ): + self.key.delete() diff --git a/test/Team.py b/test/Team.py index 2b02f941..37fbc820 100644 --- a/test/Team.py +++ b/test/Team.py @@ -1,49 +1,49 @@ -import Framework - -class Team( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.org = self.g.get_organization( "BeaverSoftware" ) - self.team = self.org.get_team( 189850 ) - - def testAttributes( self ): - self.assertEqual( self.team.id, 189850 ) - self.assertEqual( self.team.members_count, 0 ) - self.assertEqual( self.team.name, "Team created by PyGithub" ) - self.assertEqual( self.team.permission, "pull" ) - self.assertEqual( self.team.repos_count, 0 ) - self.assertEqual( self.team.url, "https://api.github.com/teams/189850" ) - - def testMembers( self ): - user = self.g.get_user( "jacquev6" ) - self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [] ) - self.assertFalse( self.team.has_in_members( user ) ) - self.team.add_to_members( user ) - self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [ "jacquev6" ] ) - self.assertTrue( self.team.has_in_members( user ) ) - self.team.remove_from_members( user ) - self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [] ) - self.assertFalse( self.team.has_in_members( user ) ) - - def testRepos( self ): - repo = self.org.get_repo( "FatherBeaver" ) - self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [] ) - self.assertFalse( self.team.has_in_repos( repo ) ) - self.team.add_to_repos( repo ) - self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [ "FatherBeaver" ] ) - self.assertTrue( self.team.has_in_repos( repo ) ) - self.team.remove_from_repos( repo ) - self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [] ) - self.assertFalse( self.team.has_in_repos( repo ) ) - - def testEditWithoutArguments( self ): - self.team.edit( "Name edited by PyGithub" ) - self.assertEqual( self.team.name, "Name edited by PyGithub" ) - - def testEditWithAllArguments( self ): - self.team.edit( "Name edited twice by PyGithub", "admin" ) - self.assertEqual( self.team.name, "Name edited twice by PyGithub" ) - self.assertEqual( self.team.permission, "admin" ) - - def testDelete( self ): - self.team.delete() +import Framework + +class Team( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.org = self.g.get_organization( "BeaverSoftware" ) + self.team = self.org.get_team( 189850 ) + + def testAttributes( self ): + self.assertEqual( self.team.id, 189850 ) + self.assertEqual( self.team.members_count, 0 ) + self.assertEqual( self.team.name, "Team created by PyGithub" ) + self.assertEqual( self.team.permission, "pull" ) + self.assertEqual( self.team.repos_count, 0 ) + self.assertEqual( self.team.url, "https://api.github.com/teams/189850" ) + + def testMembers( self ): + user = self.g.get_user( "jacquev6" ) + self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [] ) + self.assertFalse( self.team.has_in_members( user ) ) + self.team.add_to_members( user ) + self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [ "jacquev6" ] ) + self.assertTrue( self.team.has_in_members( user ) ) + self.team.remove_from_members( user ) + self.assertListKeyEqual( self.team.get_members(), lambda u: u.login, [] ) + self.assertFalse( self.team.has_in_members( user ) ) + + def testRepos( self ): + repo = self.org.get_repo( "FatherBeaver" ) + self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [] ) + self.assertFalse( self.team.has_in_repos( repo ) ) + self.team.add_to_repos( repo ) + self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [ "FatherBeaver" ] ) + self.assertTrue( self.team.has_in_repos( repo ) ) + self.team.remove_from_repos( repo ) + self.assertListKeyEqual( self.team.get_repos(), lambda r: r.name, [] ) + self.assertFalse( self.team.has_in_repos( repo ) ) + + def testEditWithoutArguments( self ): + self.team.edit( "Name edited by PyGithub" ) + self.assertEqual( self.team.name, "Name edited by PyGithub" ) + + def testEditWithAllArguments( self ): + self.team.edit( "Name edited twice by PyGithub", "admin" ) + self.assertEqual( self.team.name, "Name edited twice by PyGithub" ) + self.assertEqual( self.team.permission, "admin" ) + + def testDelete( self ): + self.team.delete() diff --git a/test/UserKey.py b/test/UserKey.py index 3d0ce9df..86b42edc 100644 --- a/test/UserKey.py +++ b/test/UserKey.py @@ -1,24 +1,24 @@ -import Framework - -class UserKey( Framework.TestCase ): - def setUp( self ): - Framework.TestCase.setUp( self ) - self.key = self.g.get_user().get_key( 2626650 ) - - def testAttributes( self ): - self.assertEqual( self.key.id, 2626650 ) - self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==" ) - self.assertEqual( self.key.title, "Key added through PyGithub" ) - self.assertEqual( self.key.url, "https://api.github.com/user/keys/2626650" ) - self.assertEqual( self.key.verified, True ) - - def testEditWithoutArguments( self ): - self.key.edit() - - def testEditWithAllArguments( self ): - self.key.edit( "Title edited by PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) - self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) - self.assertEqual( self.key.title, "Title edited by PyGithub" ) - - def testDelete( self ): - self.key.delete() +import Framework + +class UserKey( Framework.TestCase ): + def setUp( self ): + Framework.TestCase.setUp( self ) + self.key = self.g.get_user().get_key( 2626650 ) + + def testAttributes( self ): + self.assertEqual( self.key.id, 2626650 ) + self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw==" ) + self.assertEqual( self.key.title, "Key added through PyGithub" ) + self.assertEqual( self.key.url, "https://api.github.com/user/keys/2626650" ) + self.assertEqual( self.key.verified, True ) + + def testEditWithoutArguments( self ): + self.key.edit() + + def testEditWithAllArguments( self ): + self.key.edit( "Title edited by PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) + self.assertEqual( self.key.key, "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5Q58YmzZjU64prR5Pk91MfeHezOTgLqDYmepYbv3qjguiHtPai1vSai5WvUv3hgf9DArXsXE5CV6yoBIhAdGtpJKExHuQ2m4XTFCdbrgfQ3ypcSdgzEiQemyTA6TWwhbuwjJ1IqJMYOVLH+FBCkD8pyIpUDO7v3vaR2TCEuNwOS7lbsRsW3OkGYnUKjaPaCTe/inrqb7I3OE8cPhWJ3dM/zzzBj22J4LCNKhjKua8TFS74xGm3lNDZ6/twQl4n4xmrH/3tG+WOJicNO3JohNHqK9T0pILnr3epEyfdkBjcG0qXApqWvH2WipJhaH6of8Gdr0Z/K/7p8QFddmwNgdPQ==" ) + self.assertEqual( self.key.title, "Title edited by PyGithub" ) + + def testDelete( self ): + self.key.delete()