def durable_vpc_table(): from historical.vpc.models import DurableVPCModel mock_dynamodb2().start() yield DurableVPCModel.create_table(read_capacity_units=1, write_capacity_units=1, wait=True) mock_dynamodb2().stop()
def durable_security_group_table(): from historical.security_group.models import DurableSecurityGroupModel mock_dynamodb2().start() yield DurableSecurityGroupModel.create_table(read_capacity_units=1, write_capacity_units=1, wait=True) mock_dynamodb2().stop()
def current_vpc_table(): """Create the Current VPC Table.""" from historical.vpc.models import CurrentVPCModel mock_dynamodb2().start() yield CurrentVPCModel.create_table(read_capacity_units=1, write_capacity_units=1, wait=True) mock_dynamodb2().stop()
def current_security_group_table(): """Create the Current Security Group Table.""" from historical.security_group.models import CurrentSecurityGroupModel mock_dynamodb2().start() yield CurrentSecurityGroupModel.create_table(read_capacity_units=1, write_capacity_units=1, wait=True) mock_dynamodb2().stop()
def setUp(self): # Test with localhost to test global secondary indices / projections self.endpoint_url = _default_endpoint_url() if self.endpoint_url: print("using local dynamodb: {}".format(self.endpoint_url)) self.region_name = None self.use_gsi = True self.use_projections = True else: print("using mock dynamodb") self.region_name = "us-west-1" self.use_gsi = False self.use_projections = False # Create a mock dynamodb table in bucket in moto # Note that we must set these as environment variables in case users # so that boto does not attempt to assume credentials from the ~/.aws/config # or IAM role. moto does not correctly pass the arguments to boto3.client(). os.environ["AWS_ACCESS_KEY_ID"] = "a" os.environ["AWS_SECRET_ACCESS_KEY"] = "b" self.mock = mock_dynamodb2() self.mock.start() self.table_prefix = "mlflow" self.store = DynamodbStore( store_uri="dynamodb:{}".format(self.table_prefix), endpoint_url=self.endpoint_url, region_name=self.region_name, use_gsi=self.use_gsi, use_projections=self.use_projections, create_tables=True, ) self._populate_tables()
def client(): with mock_dynamodb2(): schema = task_schema["KeySchema"] indexes = task_schema["GlobalSecondaryIndexes"] dynamodb_backend2.create_table("test", schema=schema, indexes=indexes) schema = release_summary_schema["KeySchema"] dynamodb_backend2.create_table( "release-summary", schema=schema, indexes=[] ) schema = study_summary_schema["KeySchema"] indexes = study_summary_schema["GlobalSecondaryIndexes"] dynamodb_backend2.create_table( "study-summary", schema=schema, indexes=indexes ) app = create_app() app.config["DYNAMO_ENDPOINT"] = None app.config["TASK_TABLE"] = "test" app.config["RELEASE_SUMMARY_TABLE"] = "release-summary" app.config["DATASERVICE_URL"] = "http://dataservice" app.config["COORDINATOR_URL"] = "http://coordinator" app.config["EGO_URL"] = "http://ego" app.config[ "AUTH0_AUD" ] = "https://kf-release-coordinator.kidsfirstdrc.org" app_context = app.app_context() app_context.push() client = app.test_client() # Allow all requests to be verified by ego mock_resp = MagicMock() mock_resp.json.return_value = True mock_resp.status_code = 200 with patch("reports.authentication.requests.get") as mock_get: mock_get.return_value = mock_resp yield client
def dynamodb(): with mock_dynamodb2(): yield boto3.client('dynamodb', region_name='us-east-1')
def dynamodb(): """Mocked DynamoDB Fixture.""" with mock_dynamodb2(): yield boto3.client('dynamodb', region_name='us-east-1')