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