Home | History | Annotate | Download | only in tests

Lines Matching refs:http

9 #      http://www.apache.org/licenses/LICENSE-2.0
17 """Http tests
19 Unit tests for the googleapiclient.http.
47 from googleapiclient.http import build_http
48 from googleapiclient.http import BatchHttpRequest
49 from googleapiclient.http import HttpMock
50 from googleapiclient.http import HttpMockSequence
51 from googleapiclient.http import HttpRequest
52 from googleapiclient.http import MAX_URI_LENGTH
53 from googleapiclient.http import MediaFileUpload
54 from googleapiclient.http import MediaInMemoryUpload
55 from googleapiclient.http import MediaIoBaseDownload
56 from googleapiclient.http import MediaIoBaseUpload
57 from googleapiclient.http import MediaUpload
58 from googleapiclient.http import _StreamSlice
59 from googleapiclient.http import set_user_agent
82 def authorize(self, http):
85 request_orig = http.request
87 # The closure that will replace 'httplib2.Http.request'.
103 http.request = new_request
106 setattr(http.request, 'credentials', self)
108 return http
110 def refresh(self, http):
191 http = HttpMockSequence([
195 http = set_user_agent(http, "my_app/5.5")
196 resp, content = http.request("http://example.com")
200 http = HttpMockSequence([
204 http = set_user_agent(http, "my_app/5.5")
205 http = set_user_agent(http, "my_library/0.1")
206 resp, content = http.request("http://example.com")
252 http = build_http()
256 http,
258 'http://example.com',
266 new_req = HttpRequest.from_json(json, http, _postproc_none)
271 self.assertEqual('http://example.com', new_req.uri)
273 self.assertEqual(http, new_req.http)
360 http = HttpMockSequence([
375 http,
394 http = HttpMockSequence([
403 http,
421 http = HttpMock(datafile('zoo.json'), {'status': '200'})
422 zoo = build('zoo', 'v1', http=http)
427 self.request.http = HttpMockSequence([
433 self.assertEqual(True, self.request.http.follow_redirects)
461 self.request.http = HttpMockSequence([
467 self.assertEqual(True, self.request.http.follow_redirects)
496 self.request.http = HttpMockSequence([
511 self.request.http = HttpMockSequence([
525 self.request.http = HttpMockSequence([
535 self.request.http = HttpMockWithErrors(
549 self.request.http = HttpMockSequence([
602 self.request.http = HttpMockSequence([
624 self.request.http = HttpMockSequence([
646 EXPECTED = """POST /someapi/v1/collection/?foo=bar HTTP/1.1
653 NO_BODY_EXPECTED = """POST /someapi/v1/collection/?foo=bar HTTP/1.1
659 NO_BODY_EXPECTED_GET = """GET /someapi/v1/collection/?foo=bar HTTP/1.1
665 RESPONSE = """HTTP/1.1 200 OK
672 Content-Type: application/http
676 HTTP/1.1 200 OK
682 Content-Type: application/http
686 HTTP/1.1 200 OK
694 Content-Type: application/http
698 HTTP/1.1 200 OK
704 Content-Type: application/http
708 HTTP/1.1 403 Access Not Configured
730 Content-Type: application/http
734 HTTP/1.1 401 Authorization Required
741 Content-Type: application/http
745 HTTP/1.1 200 OK
753 Content-Type: application/http
757 HTTP/1.1 200 OK
834 http = HttpMock(datafile('zoo.json'), headers={'status': '200'})
839 http,
846 self.assertEqual(uri, http.uri)
847 self.assertEqual(str, type(http.uri))
848 self.assertEqual(method, http.method)
849 self.assertEqual(str, type(http.method))
853 http = HttpMock(None, headers={'status': 200})
857 http,
863 self.assertEqual('', http.headers.get('content-type'))
915 http = HttpMockSequence(resp_seq)
920 http,
941 http = HttpMockSequence(resp_seq)
946 http,
962 http = HttpMockSequence([
970 http,
985 http = HttpMockSequence([
993 http,
1008 http = HttpMockSequence([
1016 http,
1031 http = HttpMockSequence([
1039 http,
1054 http = HttpMockSequence([
1062 http,
1196 from googleapiclient.http import MAX_BATCH_LIMIT
1231 http = HttpMockSequence([
1236 batch.execute(http=http)
1247 http = HttpMockSequence([
1253 batch.execute(http=http)
1263 self.assertEqual('Content-Type: application/http', header)
1270 http = HttpMockSequence([
1276 batch.execute(http=http)
1303 http = HttpMockSequence([
1309 cred.authorize(http)
1312 batch.execute(http=http)
1329 http = HttpMockSequence([
1344 self.request1.http = creds_http_1
1345 self.request2.http = creds_http_2
1349 batch.execute(http=http)
1371 http = HttpMockSequence([
1386 self.request1.http = creds_http_1
1387 self.request2.http = creds_http_2
1391 batch.execute(http=http)
1406 http = HttpMockSequence([
1411 batch.execute(http=http)
1421 http = HttpMockSequence([
1426 batch.execute(http=http)
1441 http = HttpMockSequence([
1453 http,
1455 'http://example.com?' + urlencode(query),
1468 self.assertEqual('GET', response['x-http-method-override'])
1512 request.execute(http=h)
1518 http = HttpMock(datafile('zoo.json'))
1519 resp, content = http.request("http://example.com")
1523 http = HttpMock(datafile('bad_request.json'), {'status': '400'})
1526 http,
1547 http = build_http()
1548 self.assertIsInstance(http.timeout, int)
1549 self.assertGreater(http.timeout, 0)
1553 http = build_http()
1554 self.assertAlmostEqual(http.timeout, 1.5, delta=0.001)
1558 http = build_http()
1559 self.assertEquals(http.timeout, 0)