Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(self):
self.out = StringIO()
self.err = StringIO()
self.ui = utils.UI(self.out, self.err)
def _deploy_app(temp_dirname):
factory = CLIFactory(temp_dirname)
config = factory.create_config_obj(
chalice_stage_name='dev',
autogen_policy=True
)
session = factory.create_botocore_session()
d = factory.create_default_deployer(session, config, UI())
region = session.get_config_variable('region')
deployed = _deploy_with_retries(d, config)
application = SmokeTestApplication(
region=region,
deployed_values=deployed,
stage_name='dev',
app_name=RANDOM_APP_NAME,
app_dir=temp_dirname,
)
return application
def setup_method(self):
self.mock_client = mock.Mock(spec=TypedAWSClient)
self.ui = mock.Mock(spec=UI)
self.executor = Executor(self.mock_client, self.ui)
def test_can_create_deletion_deployer():
session = botocore.session.get_session()
deployer = create_deletion_deployer(TypedAWSClient(session), UI())
assert isinstance(deployer, Deployer)
def _delete_app(application, temp_dirname):
factory = CLIFactory(temp_dirname)
config = factory.create_config_obj(
chalice_stage_name='dev',
autogen_policy=True
)
session = factory.create_botocore_session()
d = factory.create_deletion_deployer(session, UI())
_deploy_with_retries(d, config)
def setup_method(self):
self.ui = mock.Mock(spec=UI)
self.reporter = DeploymentReporter(ui=self.ui)
def delete(ctx, profile, stage):
# type: (click.Context, str, str) -> None
factory = ctx.obj['factory'] # type: CLIFactory
factory.profile = profile
config = factory.create_config_obj(chalice_stage_name=stage)
session = factory.create_botocore_session()
d = factory.create_deletion_deployer(session=session, ui=UI())
d.deploy(config, chalice_stage_name=stage)
def create_default_deployer(session, config, ui):
# type: (Session, Config, UI) -> Deployer
client = TypedAWSClient(session)
osutils = OSUtils()
return Deployer(
application_builder=ApplicationGraphBuilder(),
deps_builder=DependencyBuilder(),
build_stage=create_build_stage(
osutils, UI(), TemplatedSwaggerGenerator(),
),
plan_stage=PlanStage(
osutils=osutils, remote_state=RemoteState(
client, config.deployed_resources(config.chalice_stage)),
),
sweeper=ResourceSweeper(),
executor=Executor(client, ui),
recorder=ResultsRecorder(osutils=osutils),
)
def generate_models(ctx, stage):
# type: (click.Context, str) -> None
"""Generate a model from Chalice routes.
Currently only supports generating Swagger 2.0 models.
"""
factory = ctx.obj['factory'] # type: CLIFactory
config = factory.create_config_obj(stage)
if not config.chalice_app.routes:
click.echo('No REST API found to generate model from.')
raise click.Abort()
swagger_generator = TemplatedSwaggerGenerator()
model = swagger_generator.generate_swagger(
config.chalice_app,
)
ui = UI()
ui.write(json.dumps(model, indent=4, cls=PlanEncoder))
ui.write('\n')