API

Runner

class ansibleci.runner.Runner(config)[source]

Runner class which executes all tests.

get_test_classes()[source]

Returns a list of all enabled test classes.

The method will only lookup the test classes on the first invoke and cache them for all further lookups.

run()[source]

Runs all enabled tests.

Config

class ansibleci.config.Config(load_defaults=True)[source]

Configuration class which can be used to work with configuration parameters.

The class is designed to work with getters and setters, so you can easily read / write config parameters by accessing the Config instance’s attributes. You can also add complete Python modules to the Config instance by calling the add_module() method.

By default all ansibleci.defaults will be loaded, however you can overwrite that in the constructor.

add_module(module)[source]

Adds configuration parameters from a Python module.

Logger

class ansibleci.logger.Logger(config)[source]

Logger class which is used to print log messages to stdout and stderr.

failed(message)[source]

Logs as whole test result as FAILED.

This method should only be used by the Runner.

info(message)[source]

Logs an informational message to stdout.

This method should only be used by the Runner.

passed(message)[source]

Logs as whole test result as PASSED.

This method should only be used by the Runner.

test_failed(message)[source]

Logs an FAILED message from inside a test.

test_passed(message)[source]

Logs an PASSED message from inside a test.

Helper

class ansibleci.helper.Helper(config)[source]

Helper class which provides common used helper methods.

get_absolute_path(path)[source]

Returns the absolute path of the path argument.

If path is already absolute, nothing changes. If the path is relative, then the BASEDIR will be prepended.

get_item_identifier(item)[source]

Returns the identifier of a (task) item, which by default is the name param of the item. If no name param is defined then the method will return “unknown”.

@todo: Update this method to consider other params when name is not defined (e.g. “include”).

get_roles()[source]

Returns a key-value dict with a roles, while the key is the role name and the value is the absolute role path.

get_roles_paths()[source]

Returns all absolute paths to the roles/ directories, while considering the BASEDIR and ROLES config variables.

get_yaml_items(dir_path, param=None)[source]

Loops through the dir_path and parses all YAML files inside the directory.

If no param is defined, then all YAML items will be returned in a list. If a param is defined, then all items will be scanned for this param and a list of all those values will be returned.

read_yaml(filename)[source]

Reads and parses a YAML file and returns the content.

Test

class ansibleci.test.Test(runner)[source]

This is the abstract class for all tests, which means all concrete test classes must inherit from this class.

failed(message)[source]

Marks a (sub-)test as failed. This will change the result of the whole test to FAILED.

get_config()[source]

Returns the Runner’s Config instance, which can be used to access configuration params.

get_helper()[source]

Returns the Runner’s Helper instance, which can be used to access common used methods.

get_runner()[source]

Returns the Runner instance which has called / instanced us.

passed(message)[source]

Marks a (sub-)test as passed. This will not change the result of the whole test.