Пример #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)