コード例 #1
0
 def setUp(self):
     super(DynamoDBTestCase, self).setUp()
     utils.clear_environment()
     os.environ['AWS_ACCESS_KEY_ID'] = str(uuid.uuid4())
     os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
     os.environ['AWS_DEFAULT_REGION'] = 'local'
     self.client = tornado_aws.AsyncAWSClient('dynamodb',
                                              endpoint=DYNAMODB_ENDPOINT)
コード例 #2
0
 def setUp(self):
     super(S3TestCase, self).setUp()
     utils.clear_environment()
     os.environ['AWS_ACCESS_KEY_ID'] = str(uuid.uuid4())
     os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
     os.environ['AWS_DEFAULT_REGION'] = 'local'
     self.client = tornado_aws.AsyncAWSClient('s3', endpoint=S3_ENDPOINT)
     self.bucket = uuid.uuid4().hex
     self.headers = {'Host': '{}.s3.amazonaws.com'.format(self.bucket)}
コード例 #3
0
def async_request():
    client = tornado_aws.AsyncAWSClient('dynamodb', use_curl=True)
    response = yield client.fetch('POST',
                                  '/',
                                  headers=HEADERS,
                                  body=json.dumps(PAYLOAD))
    x = json.loads(response.body.decode('utf-8'))
    pprint.pprint(x)
    ioloop.IOLoop.instance().stop()
コード例 #4
0
 def __init__(self, **kwargs):
     self.logger = LOGGER.getChild(self.__class__.__name__)
     if os.environ.get('DYNAMODB_ENDPOINT', None):
         kwargs.setdefault('endpoint', os.environ['DYNAMODB_ENDPOINT'])
     self._client = tornado_aws.AsyncAWSClient('dynamodb', **kwargs)
     self._ioloop = kwargs.get('io_loop', ioloop.IOLoop.current())
     self._max_retries = kwargs.get(
         'max_retries',
         os.environ.get('DYNAMODB_MAX_RETRIES', self.DEFAULT_MAX_RETRIES))
     self._instrumentation_callback = kwargs.get('instrumentation_callback')
     self._on_error = kwargs.get('on_error_callback')
コード例 #5
0
 def test_invalid_endpoint(self):
     client = tornado_aws.AsyncAWSClient('dynamodb',
                                         endpoint='http://localhost',
                                         use_curl=True)
     definition = copy.deepcopy(self.TABLE_DEFINITION)
     definition['TableName'] = str(uuid.uuid4())
     with self.assertRaises(httpclient.HTTPError):
         yield client.fetch('POST',
                            '/',
                            body=json.dumps(definition).encode('utf-8'),
                            headers={
                                'x-amz-target':
                                'DynamoDB_20120810.CreateTable',
                                'Content-Type': 'application/x-amz-json-1.0'
                            })