Esempio n. 1
0
    def test_assert_as_readable(self):
        with open(os.path.join(base_path, 'test_open.txt'), 'rb') as f:
            f = Client.assert_as_readable(f)
            f.read()

        try:
            Client.assert_as_readable('readable')
        except ValueError as e:
            self.assertEqual('The value is not a readable', str(e))
Esempio n. 2
0
 def get_snapshot_block_with_options(self, request, headers, runtime):
     UtilClient.validate_model(request)
     query = {}
     if not UtilClient.is_unset(request.client_token):
         query['ClientToken'] = request.client_token
     if not UtilClient.is_unset(request.block_index):
         query['BlockIndex'] = request.block_index
     if not UtilClient.is_unset(request.block_token):
         query['BlockToken'] = request.block_token
     if not UtilClient.is_unset(request.snapshot_id):
         query['SnapshotId'] = request.snapshot_id
     req = open_api_models.OpenApiRequest(
         headers=headers, query=OpenApiUtilClient.query(query))
     res = snapshot_20210315_models.GetSnapshotBlockResponse()
     tmp = UtilClient.assert_as_map(
         self.do_roarequest('GetSnapshotBlock', '2021-03-15', 'HTTPS',
                            'GET', 'AK', '/snapshots/block', 'binary', req,
                            runtime))
     if not UtilClient.is_unset(tmp.get('body')):
         resp_body = UtilClient.assert_as_readable(tmp.get('body'))
         res.body = resp_body
     if not UtilClient.is_unset(tmp.get('headers')):
         resp_headers = UtilClient.assert_as_map(tmp.get('headers'))
         res.headers = UtilClient.stringify_map_value(resp_headers)
     return res