示例#1
0
def test_all_mandatory_tags_exist():
    tagger = Tagger(environment_name="prod")
    tags = tagger.create_tags("test")
    for mandatory_tag in [
            "Name",
            "business-unit",
            "application",
            "owner",
            "is-production",
    ]:
        assert mandatory_tag in tags.keys()
    WebhookFilterGroupArgs,
    WebhookFilterGroupFilterArgs,
)
from pulumi_aws.codebuild.source_credential import SourceCredential
from pulumi_aws.iam import (
    GetPolicyDocumentStatementArgs,
    GetPolicyDocumentStatementPrincipalArgs,
    Role,
    RolePolicy,
    get_policy_document,
)

tagger = Tagger(
    environment_name="alpha",
    source_code=(
        "https://github.com/moj-analytical-services/"
        "data-engineering-database-access-deploy"
    ),
)

GIT_CRYPT_KEY = Config().require("git_crypt_key")
GITHUB_TOKEN = Config().require("github_token")

account_id = get_caller_identity().account_id

assume_role_policy = get_policy_document(
    statements=[
        GetPolicyDocumentStatementArgs(
            actions=["sts:AssumeRole"],
            effect="Allow",
            principals=[
示例#3
0
def test_is_production(input, output):
    tagger = Tagger(environment_name=input)
    print(tagger._global_tags)
    tags = tagger.create_tags("test")
    assert tags["is-production"] == output
示例#4
0
def test_create_tags_overwrite():
    tagger = Tagger(environment_name="prod")
    tags = tagger.create_tags("test")
    assert tags["business-unit"] == "Platforms"
    tags = tagger.create_tags("test", business_unit="HQ")
    assert tags["business-unit"] == "HQ"
示例#5
0
def test_kwarg_tag_names():
    tagger = Tagger(environment_name="prod", Extra_Global_Tag="test")
    tags = tagger.create_tags("test", Extra_Local_Tag="test")
    assert tags["extra-global-tag"] == "test"
    assert tags["extra-local-tag"] == "test"
示例#6
0
def test_kwarg_passthrough():
    tagger = Tagger(environment_name="prod", extra_tag="test")
    tags = tagger.create_tags("test")
    assert tags["extra-tag"] == "test"
示例#7
0
def test_invalid_business_unit():
    with pytest.raises(ValueError):
        Tagger(environment_name="prod", business_unit="DASHRAS")
    tagger = Tagger(environment_name="prod")
    with pytest.raises(ValueError):
        tagger.create_tags("test", business_unit="DASHRAS")
示例#8
0
def test_valid_business_unit(input):
    tagger = Tagger(environment_name="prod", business_unit=input)
    tagger.create_tags("test", business_unit=input)
示例#9
0
def test_invalid_kwarg():
    with pytest.raises(KeyError):
        Tagger(environment_name="prod", is_production=True)
    tagger = Tagger(environment_name="prod")
    with pytest.raises(KeyError):
        tagger.create_tags("test", is_production=True)