コード例 #1
0
ファイル: test_http.py プロジェクト: eac2192/ticket_scalper
 def test_media_io_base_upload_from_file_object(self):
     f = open(datafile("small.png"), "r")
     upload = MediaIoBaseUpload(fh=f, 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()
コード例 #2
0
 def test_media_io_base_upload_from_file_object(self):
   f = open(datafile('small.png'), 'r')
   upload = MediaIoBaseUpload(
       fd=f, 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()
コード例 #3
0
 def test_media_io_base_upload_from_file_object(self):
   f = open(datafile('small.png'), 'r')
   upload = MediaIoBaseUpload(
       fd=f, 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()
コード例 #4
0
ファイル: test_http.py プロジェクト: eac2192/ticket_scalper
    def test_media_io_base_upload_from_string_io(self):
        f = open(datafile("small.png"), "r")
        fh = StringIO.StringIO(f.read())
        f.close()

        upload = MediaIoBaseUpload(fh=fh, mimetype="image/png", chunksize=500, resumable=True)
        self.assertEqual("image/png", upload.mimetype())
        self.assertEqual(None, upload.size())
        self.assertEqual(True, upload.resumable())
        self.assertEqual(500, upload.chunksize())
        self.assertEqual("PNG", upload.getbytes(1, 3))
        f.close()
コード例 #5
0
ファイル: test_http.py プロジェクト: eac2192/ticket_scalper
    def test_media_io_base_upload_from_file_io(self):
        try:
            import io

            fh = io.FileIO(datafile("small.png"), "r")
            upload = MediaIoBaseUpload(fh=fh, 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
コード例 #6
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(None, upload.size())
    self.assertEqual(True, upload.resumable())
    self.assertEqual(500, upload.chunksize())
    self.assertEqual('PNG', upload.getbytes(1, 3))
    f.close()
コード例 #7
0
  def test_media_io_base_upload_from_file_io(self):
    try:
      import io

      fd = io.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('PNG', upload.getbytes(1, 3))
    except ImportError:
      pass
コード例 #8
0
  def test_media_io_base_upload_from_file_io(self):
    try:
      import io

      fd = io.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('PNG', upload.getbytes(1, 3))
    except ImportError:
      pass
コード例 #9
0
    def test_media_io_base_upload_from_string_io(self):
        f = open(datafile('small.png'), 'rb')
        fd = io.BytesIO(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(b'PNG', upload.getbytes(1, 3))
        f.close()