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)
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)}
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()
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')
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' })