def test_media_io_base_upload_from_file_io(self):
   fd = FileIO(datafile('small.png'), 'r')
   upload = MediaIoBaseUpload(
       fd=fd, mimetype='image/png', chunksize=500, resumable=True)
   self.assertEqual('image/png', upload.mimetype())
   self.assertEqual(190, upload.size())
   self.assertEqual(True, upload.resumable())
   self.assertEqual(500, upload.chunksize())
   self.assertEqual(b'PNG', upload.getbytes(1, 3))
 def test_media_io_base_upload_from_file_io(self):
   fd = FileIO(datafile('small.png'), 'r')
   upload = MediaIoBaseUpload(
       fd=fd, mimetype='image/png', chunksize=500, resumable=True)
   self.assertEqual('image/png', upload.mimetype())
   self.assertEqual(190, upload.size())
   self.assertEqual(True, upload.resumable())
   self.assertEqual(500, upload.chunksize())
   self.assertEqual(b'PNG', upload.getbytes(1, 3))
Ejemplo n.º 3
0
  def test_media_io_base_upload_from_string_io(self):
    f = open(datafile('small.png'), 'r')
    fd = StringIO.StringIO(f.read())
    f.close()

    upload = MediaIoBaseUpload(
        fd=fd, mimetype='image/png', chunksize=500, resumable=True)
    self.assertEqual('image/png', upload.mimetype())
    self.assertEqual(190, upload.size())
    self.assertEqual(True, upload.resumable())
    self.assertEqual(500, upload.chunksize())
    self.assertEqual('PNG', upload.getbytes(1, 3))
    f.close()
Ejemplo n.º 4
0
  def test_media_io_base_upload_from_bytes(self):
    try:
      import io

      f = open(datafile('small.png'), 'r')
      fd = io.BytesIO(f.read())
      upload = MediaIoBaseUpload(
          fd=fd, mimetype='image/png', chunksize=500, resumable=True)
      self.assertEqual('image/png', upload.mimetype())
      self.assertEqual(190, upload.size())
      self.assertEqual(True, upload.resumable())
      self.assertEqual(500, upload.chunksize())
      self.assertEqual('PNG', upload.getbytes(1, 3))
    except ImportError:
      pass