Exemplo n.º 1
0
	def test_batch_delete_move_copy(self):
		r = rs.Rs()
		e1 = rs.EntryPath(bucket_name, key)
		e2 = rs.EntryPath(bucket_name, key2)
		e3 = rs.EntryPath(bucket_name, key3)
		e4 = rs.EntryPath(bucket_name, key4)
		r.batch_delete([e2, e3, e4])
		
		# copy
		entries = [
			rs.EntryPathPair(e1, e2),
			rs.EntryPathPair(e1, e3),
		]
		ret, err = r.batch_copy(entries)
		assert err is None
		self.assertEqual(ret[0]["code"], 200)
		self.assertEqual(ret[1]["code"], 200)
		
		ret, err = r.batch_move([rs.EntryPathPair(e2, e4)])
		assert err is None
		self.assertEqual(ret[0]["code"], 200)
		
		ret, err = r.batch_delete([e3, e4])
		assert err is None
		self.assertEqual(ret[0]["code"], 200)
		
		r.batch_delete([e2, e3, e4])
Exemplo n.º 2
0
    def test_block(self):
        policy = auth_token.PutPolicy(bucket)
        uptoken = policy.token()
        client = auth_up.Client(uptoken)

        rets = [0, 0]
        data_slice_2 = "\nbye!"
        ret, err = resumable_io.mkblock(client, len(data_slice_2),
                                        data_slice_2)
        assert err is None, err
        self.assertEqual(ret["crc32"], zlib.crc32(data_slice_2))

        extra = resumable_io.PutExtra(bucket)
        extra.mimetype = "text/plain"
        extra.progresses = [ret]
        lens = 0
        for i in xrange(0, len(extra.progresses)):
            lens += extra.progresses[i]["offset"]

        key = "sdk_py_resumable_block_4"
        ret, err = resumable_io.mkfile(client, key, lens, extra)
        assert err is None, err
        self.assertEqual(ret["hash"], "FtCFo0mQugW98uaPYgr54Vb1QsO0",
                         "hash not match")
        rs.Rs().delete(bucket, key)
Exemplo n.º 3
0
	def test_stat(self):
		r = rs.Rs()
		ret, err = r.stat(bucket_name, key)
		assert err is None
		assert ret is not None
		
		# error
		_, err = r.stat(bucket_name, noexist_key)
		assert err is not None
Exemplo n.º 4
0
	def test_batch_stat(self):
		r = rs.Rs()
		entries = [
			rs.EntryPath(bucket_name, key),
			rs.EntryPath(bucket_name, key2),
		]
		ret, err = r.batch_stat(entries)
		assert err is None
		self.assertEqual(ret[0]["code"], 200)
		self.assertEqual(ret[1]["code"], 612)
Exemplo n.º 5
0
 def test_put(self):
     policy = auth_token.PutPolicy(bucket)
     extra = resumable_io.PutExtra(bucket)
     extra.bucket = bucket
     key = "sdk_py_resumable_block_5"
     localfile = "../demo-pic.jpeg"
     ret, err = resumable_io.put_file(policy.token(), key, localfile, extra)
     assert err is None, err
     self.assertEqual(ret["hash"], "FuoNzfC-yMVcglmW8hAcilDaKh5C",
                      "hash not match")
     rs.Rs().delete(bucket, key)
Exemplo n.º 6
0
	def test_delete_move_copy(self):
		r = rs.Rs()
		r.delete(bucket_name, key2)
		r.delete(bucket_name, key3)
		
		ret, err = r.copy(bucket_name, key, bucket_name, key2)
		assert err is None, err
		
		ret, err = r.move(bucket_name, key2, bucket_name, key3)
		assert err is None, err
		
		ret, err = r.delete(bucket_name, key3)
		assert err is None, err
		
		# error
		_, err = r.delete(bucket_name, key2)
		assert err is not None
		
		_, err = r.delete(bucket_name, key3)
		assert err is not None