Changed to a command pattern for requests.
This commit is contained in:
@@ -28,6 +28,7 @@ import re
|
||||
import uritemplate
|
||||
import urllib
|
||||
import urlparse
|
||||
from apiclient.http import HttpRequest
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
@@ -228,10 +229,8 @@ def createResource(http, baseUrl, model, resourceName, resourceDesc,
|
||||
url = urlparse.urljoin(self._baseUrl, expanded_url + query)
|
||||
|
||||
logging.info('URL being requested: %s' % url)
|
||||
resp, content = self._http.request(
|
||||
url, method=httpMethod, headers=headers, body=body)
|
||||
|
||||
return self._model.response(resp, content)
|
||||
return HttpRequest(self._http, url, method=httpMethod, body=body,
|
||||
headers=headers, postproc=self._model.response)
|
||||
|
||||
docs = ['A description of how to use this function\n\n']
|
||||
for arg in argmap.iterkeys():
|
||||
@@ -271,7 +270,8 @@ def createResource(http, baseUrl, model, resourceName, resourceDesc,
|
||||
logging.info('URL being requested: %s' % url)
|
||||
resp, content = self._http.request(url, method='GET', headers=headers)
|
||||
|
||||
return self._model.response(resp, content)
|
||||
return HttpRequest(self._http, url, method='GET',
|
||||
headers=headers, postproc=self._model.response)
|
||||
|
||||
setattr(theclass, methodName, method)
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@ class BuzzFunctionalTest(unittest.TestCase):
|
||||
max_results = 2
|
||||
activities = buzz.activities().list(userId='googlebuzz', scope='@self',
|
||||
max_comments=max_results*2 ,max_liked=max_results*3,
|
||||
max_results=max_results)['items']
|
||||
max_results=max_results).execute()['items']
|
||||
activity_count = len(activities)
|
||||
self.assertEquals(max_results, activity_count)
|
||||
|
||||
@@ -58,7 +58,8 @@ class MainHandler(webapp.RequestHandler):
|
||||
http = c.credentials.authorize(http)
|
||||
p = build("buzz", "v1", http=http)
|
||||
activities = p.activities()
|
||||
activitylist = activities.list(scope='@consumption', userId='@me')
|
||||
activitylist = activities.list(scope='@consumption',
|
||||
userId='@me').execute()
|
||||
logging.info(activitylist)
|
||||
path = os.path.join(os.path.dirname(__file__), 'welcome.html')
|
||||
logout = users.create_logout_url('/')
|
||||
|
||||
@@ -28,7 +28,7 @@ def main():
|
||||
|
||||
p = build("buzz", "v1", http=http)
|
||||
activities = p.activities()
|
||||
activitylist = activities.list(scope='@self', userId='@me')
|
||||
activitylist = activities.list(scope='@self', userId='@me').execute()
|
||||
print activitylist['items'][0]['title']
|
||||
activities.insert(userId='@me', body={
|
||||
'title': 'Testing insert',
|
||||
@@ -36,7 +36,7 @@ def main():
|
||||
'content': u'Just a short note to show that insert is working. ☄',
|
||||
'type': 'note'}
|
||||
}
|
||||
)
|
||||
).execute()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -27,7 +27,7 @@ def main():
|
||||
http = credentials.authorize(http)
|
||||
|
||||
p = build("moderator", "v1", http=http)
|
||||
print p.submissions().list(seriesId="7035", topicId="64")
|
||||
print p.submissions().list(seriesId="7035", topicId="64").execute()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user