Example #1
0
 def test_serialize_request_no_body(self):
     batch = BatchHttpRequest()
     request = HttpRequest(
         None,
         None,
         'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
         method='POST',
         body='',
         headers={'content-type': 'application/json'},
         methodId=None,
         resumable=None)
     s = batch._serialize_request(request).splitlines()
     self.assertEqual(NO_BODY_EXPECTED.splitlines(), s)
Example #2
0
 def test_serialize_request_no_body(self):
   batch = BatchHttpRequest()
   request = HttpRequest(
       None,
       None,
       'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
       method='POST',
       body='',
       headers={'content-type': 'application/json'},
       methodId=None,
       resumable=None)
   s = batch._serialize_request(request).splitlines()
   self.assertEquals(s, NO_BODY_EXPECTED.splitlines())
Example #3
0
 def test_serialize_request_no_body(self):
     batch = BatchHttpRequest()
     request = HttpRequest(
         None,
         None,
         "https://www.googleapis.com/someapi/v1/collection/?foo=bar",
         method="POST",
         body="",
         headers={"content-type": "application/json"},
         methodId=None,
         resumable=None,
     )
     s = batch._serialize_request(request).splitlines()
     self.assertEqual(NO_BODY_EXPECTED.splitlines(), s)
  def test_serialize_request_media_body(self):
    batch = BatchHttpRequest()
    f = open(datafile('small.png'))
    body = f.read()
    f.close()

    request = HttpRequest(
        None,
        None,
        'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
        method='POST',
        body=body,
        headers={'content-type': 'application/json'},
        methodId=None,
        resumable=None)
    s = batch._serialize_request(request).splitlines()
Example #5
0
    def test_serialize_request_media_body(self):
        batch = BatchHttpRequest()
        f = open(datafile('small.png'))
        body = f.read()
        f.close()

        request = HttpRequest(
            None,
            None,
            'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
            method='POST',
            body=body,
            headers={'content-type': 'application/json'},
            methodId=None,
            resumable=None)
        # Just testing it shouldn't raise an exception.
        s = batch._serialize_request(request).splitlines()
Example #6
0
    def test_serialize_request_media_body(self):
        batch = BatchHttpRequest()
        f = open(datafile("small.png"))
        body = f.read()
        f.close()

        request = HttpRequest(
            None,
            None,
            "https://www.googleapis.com/someapi/v1/collection/?foo=bar",
            method="POST",
            body=body,
            headers={"content-type": "application/json"},
            methodId=None,
            resumable=None,
        )
        # Just testing it shouldn't raise an exception.
        s = batch._serialize_request(request).splitlines()