runway.cfngin.blueprints.testutil module

Provides a sublass of unittest.TestCase for testing blueprints.

runway.cfngin.blueprints.testutil.diff(first, second)[source]

Human readable differ.

class runway.cfngin.blueprints.testutil.BlueprintTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Extends the functionality of unittest.TestCase for testing blueprints.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

OUTPUT_PATH = 'tests/fixtures/blueprints'
assertRenderedBlueprint(blueprint)[source]

Test that the rendered blueprint json matches the expected result.

Result files are to be stored in the repo as test/fixtures/blueprints/${blueprint.name}.json.

class runway.cfngin.blueprints.testutil.YamlDirTestGenerator[source]

Bases: object

Generate blueprint tests from yaml config files.

This class creates blueprint tests from yaml files with a syntax similar to CFNgin configuration syntax. For example:

namespace: test
stacks:
    - name: test_sample
    class_path: blueprints.test.Sample
    variables:
        var1: value1

Will create a test for the specified blueprint, passing that variable as part of the test.

The test will generate a .json file for this blueprint, and compare it with the stored result.

By default, the generator looks for files named test_*.yaml in its same directory. In order to use it, subclass it in a directory containing such tests, and name the class with a pattern that will include it in nosetests’ tests (for example, TestGenerator).

The subclass may override some @property definitions:

base_class

By default, the generated tests are subclasses or runway.cfngin.blueprints.testutil.BlueprintTestCase. In order to change this, set this property to the desired base class.

yaml_dirs:

By default, the directory where the generator is subclassed is searched for test files. Override this array for specifying more directories. These must be relative to the directory in which the subclass lives in. Globs may be used. Default: ['.']. Example override: ['.', 'tests/*/']

yaml_filename:

By default, the generator looks for files named test_*.yaml. Use this to change this pattern. Globs may be used.

Instantiate class.

property base_class

Return the baseclass.

property yaml_dirs

Yaml directories.

property yaml_filename

Yaml filename.

test_generator()[source]

Test generator.