How to use the stacker.blueprints.testutil.BlueprintTestCase function in stacker

To help you get started, we’ve selected a few stacker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remind101 / stacker_blueprints / tests / test_generic.py View on Github external
import unittest

from stacker.blueprints.testutil import BlueprintTestCase
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable

from stacker_blueprints.generic import GenericResourceCreator


class TestGenericResourceCreator(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))

    def test_create_template(self):
        blueprint = GenericResourceCreator(
            'test_generic_GenericResourceCreator', self.ctx
        )
        blueprint.resolve_variables(
            [
                Variable('Class', 'ec2.Volume'),
                Variable('Output', 'VolumeId'),
                Variable('Properties', {
                    'VolumeType': 'gp2',
                    'Size': '600',
                    'Encrypted': 'true',
                    'AvailabilityZone': 'us-east-1b',
github remind101 / stacker_blueprints / tests / test_route53.py View on Github external
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable

from stacker_blueprints.route53 import (
  DNSRecords,
  get_record_set_md5,
)

from stacker.blueprints.testutil import BlueprintTestCase


class TestRoute53(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))

    def test_create_template_hosted_zone_id(self):
        blueprint = DNSRecords('route53_dnsrecords', self.ctx)
        blueprint.resolve_variables(
            [
                Variable(
                    "RecordSets",
                    [
                        {
                            "Name": "host.testdomain.com.",
                            "Type": "A",
                            "ResourceRecords": ["10.0.0.1"],
                        },
                        {
github remind101 / stacker_blueprints / tests / test_dynamodb.py View on Github external
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker.blueprints.testutil import BlueprintTestCase

import stacker_blueprints.dynamodb

class TestDynamoDB(BlueprintTestCase):
    def setUp(self):
        self.dynamodb_variables = [
            Variable(
              'Tables',
              {
                "UserTable": {
                  "TableName": "test-user-table",
                  "KeySchema": [
                    {
                      "AttributeName": "id",
                      "KeyType": "HASH",
                    },
                    {
                      "AttributeName": "name",
                      "KeyType": "RANGE",
                    },
github remind101 / stacker_blueprints / tests / test_s3.py View on Github external
import unittest
from stacker.context import Context, Config
from stacker.variables import Variable
from stacker_blueprints.s3 import Buckets
from stacker.blueprints.testutil import BlueprintTestCase


class TestBlueprint(BlueprintTestCase):
    def setUp(self):
        self.variables = [
            Variable('Buckets', {
                'Simple': {},
                'Cycle': {
                    'LifecycleConfiguration': {
                        'Rules': [{
                            'Status': 'Enabled',
                            'ExpirationInDays': 40,
                        }],
                    },
                }
            }),
            Variable('ReadRoles', [
                'Role1',
                'Role2',
github remind101 / stacker_blueprints / tests / test_efs.py View on Github external
],
            'Tags': [{'Key': 'Foo', 'Value': 'Bar'}]
        },
        'EfsSg2': {
            'GroupDescription': 'EFS SG 2',
            'SecurityGroupIngress': [
                {'IpProtocol': 'tcp', 'FromPort': 2049, 'ToPort': 2049,
                 'SourceSecurityGroupId': 'sg-11111111'}
            ]
        }
    },
    'ExtraSecurityGroups': ['sg-22222222', 'sg-33333333']
}


class TestElasticFileSystem(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context({'namespace': 'test'})

    def test_create_template(self):
        blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
        variables = EFS_VARIABLES
        blueprint.resolve_variables(
            [Variable(k, v) for k, v in variables.items()])
        blueprint.create_template()
        self.assertRenderedBlueprint(blueprint)

    def test_validate_security_group_count_empty(self):
        blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
        variables = EFS_VARIABLES.copy()
        variables['SecurityGroups'] = {}
        variables['ExtraSecurityGroups'] = []
github remind101 / stacker_blueprints / tests / test_sns.py View on Github external
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker_blueprints.sns import Topics
from stacker.blueprints.testutil import BlueprintTestCase

class TestBlueprint(BlueprintTestCase):
    def setUp(self):
        self.variables = [
            Variable('Topics', {
                'WithoutSubscription': {
                    'DisplayName': 'SampleTopicWithoutSub',
                },
                'Example': {
                    'DisplayName': 'ExampleTopic',
                    'Subscription': [
                        {
                            'Endpoint': 'arn:aws:sqs:us-east-1:123456788901:example-queue',
                            'Protocol': 'sqs',
                        },
                        {
                            'Endpoint': 'postmaster@example.com',
                            'Protocol': 'email',
github remind101 / stacker_blueprints / tests / test_sqs.py View on Github external
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker_blueprints.sqs import Queues
from stacker.blueprints.testutil import BlueprintTestCase

class TestBlueprint(BlueprintTestCase):
    def setUp(self):
        self.variables = [
            Variable('Queues', {
                'Simple': {
                    'DelaySeconds': 15,
                    'MaximumMessageSize': 4096,
                    'ReceiveMessageWaitTimeSeconds': 15,
                    'VisibilityTimeout': 600,
                },
                'Fifo': {
                    'FifoQueue': True,
                    'QueueName': 'Fifo.fifo',
                },
                'RedrivePolicy': {
                    'RedrivePolicy': {
                        'deadLetterTargetArn': 'arn:aws:sqs:us-east-1:123456789:dlq',
github remind101 / stacker_blueprints / tests / test_kms.py View on Github external
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable

from stacker_blueprints.kms import Key

from stacker.blueprints.testutil import BlueprintTestCase


class TestKmsKey(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))

    def test_kms_key(self):
        blueprint = Key('kms_key_a', self.ctx)
        blueprint.resolve_variables(
            [
                Variable("KeyAlias", "alias/a-test-key"),
                Variable("Properties", {"Description": "a KMS test-key."}),
            ]
        )
        blueprint.create_template()
        self.assertRenderedBlueprint(blueprint)

    def test_kms_key_alias_not_in_keyalias(self):
        blueprint = Key('kms_key_b', self.ctx)
github remind101 / stacker_blueprints / tests / test_aws_lambda.py View on Github external
Variable(
                    "Code",
                    Code(S3Bucket="test_bucket", S3Key="code_key")
                ),
                Variable("Description", "Test function."),
                Variable("Environment", {"TEST_NAME": "test_value"}),
                Variable("Runtime", "python2.7"),
                Variable("AliasName", "prod"),
                Variable("AliasVersion", "1")
            ]
        )
        blueprint.create_template()
        self.assertRenderedBlueprint(blueprint)


class TestFunctionScheduler(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context({'namespace': 'test'})

    def test_create_template(self):
        blueprint = FunctionScheduler('test_aws_lambda_FunctionScheduler',
                                      self.ctx)
        blueprint.resolve_variables(
            [
                Variable(
                    "CloudwatchEventsRule",
                    {
                        "MyTestFuncSchedule": {
                            "Description": "The AWS Lambda schedule for "
                                           "my-powerful-test-function",
                            "ScheduleExpression": "rate(15 minutes)",
                            "State": "ENABLED",
github remind101 / stacker_blueprints / tests / test_cloudwatch_logs.py View on Github external
import unittest

from stacker.blueprints.testutil import BlueprintTestCase
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable

from stacker_blueprints.cloudwatch_logs import SubscriptionFilters

from troposphere import GetAtt, Ref


class TestSubscriptionFilters(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))

    def test_create_template(self):
        blueprint = SubscriptionFilters(
            'test_cloudwatch_logs_subscription_filters',
            self.ctx
        )

        blueprint.resolve_variables(
            [
                Variable(
                    "SubscriptionFilters",
                    {
                        "Filter1": {
                            "DestinationArn": GetAtt("KinesisStream1", "Arn"),