#NEWLINE# def test_responseful( self ) : #NEWLINE# #INDENT# request = { #NEWLINE# #INDENT# 'uri' : mox . Func ( self . saver ( 'uri' ) ) , #NEWLINE# 'method' : 'POST' , #NEWLINE# 'headers' : mox . Func ( self . saver ( 'headers' ) ) , #NEWLINE# 'body' : mox . Func ( self . saver ( 'body' ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# response = { #NEWLINE# #INDENT# 'status' : 200 , #NEWLINE# 'content-type' : 'application/json' , #NEWLINE# #UNINDENT# } #NEWLINE# response_content = '{"blahdeblah": true, "anotherthing": "2010-07-06T16:17:05Z"}' #NEWLINE# http = typepad . TypePadClient ( ) #NEWLINE# typepad . client = http #NEWLINE# http . add_credentials ( OAuthConsumer ( 'consumertoken' , 'consumersecret' ) , OAuthToken ( 'tokentoken' , 'tokensecret' ) , domain = 'api.typepad.com' ) #NEWLINE# mock = mox . Mox ( ) #NEWLINE# mock . StubOutWithMock ( http , 'request' ) #NEWLINE# http . request ( ** request ) . AndReturn ( ( httplib2 . Response ( response ) , response_content ) ) #NEWLINE# mock . ReplayAll ( ) #NEWLINE# class Moose ( typepad . TypePadObject ) : #NEWLINE# #INDENT# class Snert ( typepad . TypePadObject ) : #NEWLINE# #INDENT# volume = typepad . fields . Field ( ) #NEWLINE# target = typepad . fields . Object ( 'User' ) #NEWLINE# #UNINDENT# class SnertResponse ( typepad . TypePadObject ) : #NEWLINE# #INDENT# blahdeblah = typepad . fields . Field ( ) #NEWLINE# anotherthing = typepad . fields . Datetime ( ) #NEWLINE# #UNINDENT# snert = typepad . fields . ActionEndpoint ( api_name = 'snert' , post_type = Snert , response_type = SnertResponse ) #NEWLINE# #UNINDENT# moose = Moose ( ) #NEWLINE# moose . _location = 'https://api.typepad.com/meese/7.json' #NEWLINE# ret = moose . snert ( volume = 10 , target = typepad . User ( display_name = 'fred' ) ) #NEWLINE# self . assert_ ( ( ret is not None ) ) #NEWLINE# self . assert_ ( isinstance ( ret , Moose . SnertResponse ) ) #NEWLINE# mock . VerifyAll ( ) #NEWLINE# self . assert_ ( self . uri ) #NEWLINE# self . assertEquals ( self . uri , 'https://api.typepad.com/meese/7/snert.json' ) #NEWLINE# self . assert_ ( self . headers ) #NEWLINE# self . assert_ ( self . body ) #NEWLINE# self . assert_ ( utils . json_equals ( { #NEWLINE# #INDENT# 'volume' : 10 , #NEWLINE# 'target' : { #NEWLINE# #INDENT# 'displayName' : 'fred' , #NEWLINE# 'objectType' : 'User' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , self . body ) )