def test_will_create_outdir_if_needed(tmpdir, stubbed_session): appdir = _create_app_structure(tmpdir) outdir = str(appdir.join('outdir')) default_params = {'autogen_policy': True} config = Config.create(project_dir=str(appdir), chalice_app=sample_app(), **default_params) options = PackageOptions(TypedAWSClient(session=stubbed_session)) p = package.create_app_packager(config, options) p.package_app(config, str(outdir), 'dev') contents = os.listdir(str(outdir)) assert 'deployment.zip' in contents assert 'sam.json' in contents
def test_can_specify_yaml_output(tmpdir, stubbed_session): appdir = _create_app_structure(tmpdir) outdir = tmpdir.mkdir('outdir') default_params = {'autogen_policy': True} config = Config.create(project_dir=str(appdir), chalice_app=sample_app(), **default_params) options = PackageOptions(TypedAWSClient(session=stubbed_session)) p = package.create_app_packager(config, options, template_format='yaml') p.package_app(config, str(outdir), 'dev') contents = os.listdir(str(outdir)) assert 'deployment.zip' in contents assert 'sam.yaml' in contents
def test_includes_layer_package_with_sam(tmpdir, stubbed_session): appdir = _create_app_structure(tmpdir) appdir.mkdir('vendor').join('hello').write('hello\n') outdir = str(appdir.join('outdir')) default_params = {'autogen_policy': True} config = Config.create(project_dir=str(appdir), chalice_app=sample_app(), automatic_layer=True, **default_params) options = PackageOptions(TypedAWSClient(session=stubbed_session)) p = package.create_app_packager(config, options) p.package_app(config, str(outdir), 'dev') contents = os.listdir(str(outdir)) assert 'deployment.zip' in contents assert 'layer-deployment.zip' in contents assert 'sam.json' in contents
def test_can_create_app_packager_with_no_autogen(tmpdir, stubbed_session): appdir = _create_app_structure(tmpdir) outdir = tmpdir.mkdir('outdir') default_params = {'autogen_policy': True} config = Config.create(project_dir=str(appdir), chalice_app=sample_app(), **default_params) options = PackageOptions(TypedAWSClient(session=stubbed_session)) p = package.create_app_packager(config, options) p.package_app(config, str(outdir), 'dev') # We're not concerned with the contents of the files # (those are tested in the unit tests), we just want to make # sure they're written to disk and look (mostly) right. contents = os.listdir(str(outdir)) assert 'deployment.zip' in contents assert 'sam.json' in contents
def test_can_create_app_packager_with_yaml_extention(tmpdir, stubbed_session): appdir = _create_app_structure(tmpdir) outdir = tmpdir.mkdir('outdir') default_params = {'autogen_policy': True} extras_file = tmpdir.join('extras.yaml') extras_file.write("foo: bar") config = Config.create(project_dir=str(appdir), chalice_app=sample_app(), **default_params) options = PackageOptions(TypedAWSClient(session=stubbed_session)) p = package.create_app_packager(config, options, merge_template=str(extras_file)) p.package_app(config, str(outdir), 'dev') contents = os.listdir(str(outdir)) assert 'deployment.zip' in contents assert 'sam.yaml' in contents
def create_package_options(self): # type: () -> PackageOptions """Create the package options that are required to target regions.""" s = Session(profile=self.profile) client = TypedAWSClient(session=s) return PackageOptions(client)