def test_nocloud(deployer, config): testdeployer = deployer.copy() assert InitializeDeployerTemplate.get("AWS", testdeployer, config) is not None assert InitializeDeployerTemplate.get("GCP", testdeployer, config) is not None with pytest.raises(NotImplementedError): InitializeDeployerTemplate.get("sdsd", testdeployer, config)
def test_aws(deployer, config, configfile): template = InitializeDeployerTemplate.aws(deployer, config) assert len(template) == 1 assert template[0]["aws"]["account-id"] == configfile["aws"].get("account") assert template[0]["aws"]["region"] == configfile["aws"].get("region") assert template[0]["aws"]["deployment-role"] == configfile["aws"].get( "deployment-role", "") assert os.path.isfile(template[0]["location"]) assert template[0]["template"]["name"] == InitializeDeployerTemplate.name( deployer) assert (template[0]["template"]["parameters"]["registry-table"] == deployer["registry"]) assert (template[0]["template"]["parameters"]["artifact-bucket"] == deployer["artifact"])
def deployer(ctx, name, cloud, artifact_bucket, registry_table, wait, dryrun, output_location): """Create artifact bucket and registry table. Initialize your deployer""" ctx.obj.require_cloud_access() cloud = cloud.upper() name = validate_name(name) artifact_bucket = validate_bucket(name, artifact_bucket) registry_table = validate_registry( name, registry_table) if cloud == "AWS" else None deployer = { "name": name, "cloud": cloud, "artifact": artifact_bucket, "registry": registry_table, } click.echo(json.dumps(deployer)) config = ctx.obj.config Compiler.build_template( deployer, InitializeDeployerTemplate.get(cloud, deployer, config), cloud=cloud, wait=wait, dryrun=dryrun, output_folder=output_location, ) save_deployer(deployer, config)
def test_aws(deployer, config, configfile): template = DeployerRepositoryTemplate.aws(deployer, config) ref_template = InitializeDeployerTemplate.aws(deployer, config) core_template = CoreDeployerTemplate.aws(deployer, config) assert len(template) == 1 assert template[0]["aws"]["account-id"] == configfile["aws"].get("account") assert template[0]["aws"]["region"] == configfile["aws"].get("region") assert template[0]["aws"]["deployment-role"] == configfile["aws"].get( "deployment-role", "") assert os.path.isfile(template[0]["location"]) assert template[0]["template"]["name"] == DeployerRepositoryTemplate.name( deployer) assert (template[0]["template"]["parameters"]["artifact-bucket"] == ref_template[0]["template"]["parameters"]["artifact-bucket"]) assert (template[0]["template"]["parameters"]["deployment-workflow"] == core_template[0]["template"]["parameters"]["deployment-workflow"])
def test_aws(deployer, config, configfile): template = CoreDeployerTemplate.aws(deployer, config) ref_template = InitializeDeployerTemplate.aws(deployer, config) assert len(template) == 1 assert template[0]["aws"]["account-id"] == configfile["aws"].get("account") assert template[0]["aws"]["region"] == configfile["aws"].get("region") assert template[0]["aws"]["deployment-role"] == configfile["aws"].get( "deployment-role", "") assert os.path.isfile(template[0]["location"]) assert template[0]["template"]["name"] == CoreDeployerTemplate.name( deployer) assert (template[0]["template"]["parameters"]["registry-table"] == ref_template[0]["template"]["parameters"]["registry-table"]) assert (template[0]["template"]["parameters"]["artifact-bucket"] == ref_template[0]["template"]["parameters"]["artifact-bucket"]) assert (template[0]["template"]["parameters"]["deployment-workflow"] == f"{deployer['name']}-deployer-core") assert (template[0]["template"]["lambda-code-key"] == f"packages/{deployer['name']}-deployer-core-stack/") assert len(template[0]["functions"]) == 1 assert os.path.isdir(template[0]["functions"][0]["location"])
def test_name(deployer): assert (InitializeDeployerTemplate.name(deployer) == "test-deployer-initialization-stack")
def test_aws_template(deployer, config, configfile): template = InitializeDeployerTemplate.aws(deployer, config) assert 0 == call(f"cfn-lint {template[0]['location']}", shell=True)