def test_build_stage(): first = mock.Mock(spec=BaseDeployStep) second = mock.Mock(spec=BaseDeployStep) build = BuildStage([first, second]) foo_resource = mock.sentinel.foo_resource bar_resource = mock.sentinel.bar_resource config = Config.create() build.execute(config, [foo_resource, bar_resource]) assert first.handle.call_args_list == [ mock.call(config, foo_resource), mock.call(config, bar_resource), ] assert second.handle.call_args_list == [ mock.call(config, foo_resource), mock.call(config, bar_resource), ]
def test_can_build_private_rest_api_custom_policy(self, tmpdir, sample_app): config = self.create_config(sample_app, app_name='rest-api-app', api_gateway_policy_file='foo.json', api_gateway_endpoint_type='PRIVATE', project_dir=str(tmpdir)) tmpdir.mkdir('.chalice').join('foo.json').write( serialize_to_json({ 'Version': '2012-10-17', 'Statement': [] })) application_builder = ApplicationGraphBuilder() build_stage = BuildStage( steps=[PolicyGenerator(osutils=OSUtils(), policy_gen=None)]) application = application_builder.build(config, stage_name='dev') build_stage.execute(config, application.resources) rest_api = application.resources[0] assert rest_api.policy.document == { 'Version': '2012-10-17', 'Statement': [] }