scenario.scenarioconfig module

scenario framework configurations.

ScenarioConfigKey

Shortcut to the ScenarioConfig.Key enum in order to make it possible to import it without the ScenarioConfig class.

SCENARIO_CONFIG

Main instance of ScenarioConfig.

class ScenarioConfig

Bases: object

scenario configuration management.

This class defines static methods that help reading scenario configurations: from the program arguments (see: Args), and the configuration database (see: ConfigDatabase).

class Key

Bases: StrEnum

scenario configuration keys.

TIMEZONE = 'scenario.timezone'

Should a specific timezone be used? String value. Default is the local timezone.

LOG_DATETIME = 'scenario.log_date_time'

Should the log lines include a timestamp? Boolean value.

LOG_CONSOLE = 'scenario.log_console'

Should the log lines be displayed in the console? Boolean value.

LOG_COLOR_ENABLED = 'scenario.log_color'

Should the log lines be colored? Boolean value.

LOG_COLOR = 'scenario.log_%s_color'

Log color per log level. Integer value.

LOG_FILE = 'scenario.log_file'

Should the log lines be written in a log file? File path string.

DEBUG_CLASSES = 'scenario.debug_classes'

Which debug classes to display? List of strings, or comma-separated string.

EXPECTED_ATTRIBUTES = 'scenario.expected_attributes'

Expected scenario attributes. List of strings, or comma-separated string.

CONTINUE_ON_ERROR = 'scenario.continue_on_error'

Should the scenario continue on error? Boolean value.

DELAY_BETWEEN_STEPS = 'scenario.delay_between_steps'

Should we wait between two step executions? Float value.

RUNNER_SCRIPT_PATH = 'scenario.runner_script_path'

Runner script path. Default is ‘bin/run-test.py’.

SCENARIO_TIMEOUT = 'scenario.scenario_timeout'

Maximum time for a scenario execution. Useful when executing campaigns. Float value.

RESULTS_EXTRA_INFO = 'scenario.results_extra_info'

Scenario attributes to display for extra info when displaying scenario results, after a campaign execution, or when executing several tests in a single command line. List of strings, or comma-separated string.

ISSUE_LEVEL_NAMES = 'scenario.issue_levels'

Issue level names. Dictionary of names (str) => int values.

ISSUE_LEVEL_ERROR = 'scenario.issue_level_error'

Issue level from and above which known issues should be considered as errors.

ISSUE_LEVEL_IGNORED = 'scenario.issue_level_ignored'

Issue level from and under which known issues should be ignored.

__init__()

Initializes the timezone cache information.

__timezone

Timezone cache information.

timezone()

Gives the timezone configuration, if set.

Returns:

Timezone configuration if set, None otherwise.

When not set, the local timezone is used.

invalidatetimezonecache()

Invalidates the timezone cache information.

logdatetimeenabled()

Determines whether the Log line should include a timestamp.

Configurable through Key.LOG_DATETIME.

logconsoleenabled()

Determines whether the log should be displayed in the console.

Configurable through Key.LOG_CONSOLE.

logoutpath()

Determines whether the log lines should be written in a log file.

Returns:

Output log file path if set, None indicates no file logging.

Configurable through Key.LOG_FILE.

logcolorenabled()

Determines whether log colors should be used when displayed in the console.

Configurable through Key.LOG_COLOR_ENABLED.

logcolor(level, default)

Retrieves the expected log color for the given log level.

Parameters:
  • level – Log level name.

  • default – Default log color.

Returns:

Log color configured, or default if not set.

Configurable through Key.LOG_COLOR.

debugclasses()

Retrieves the debug classes configured.

Returns:

List of debug classes.

Adds debug classes defined by the program arguments (see args.Args.debug_classes) plus those defined by the configurations (see Key.DEBUG_CLASSES).

expectedscenarioattributes()

Retrieves the user scenario expected attributes.

Configurable through Key.EXPECTED_ATTRIBUTES.

continueonerror()

Determines whether the test should continue when a step ends in error.

Configurable through Key.CONTINUE_ON_ERROR.

delaybetweensteps()

Retrieves the expected delay between steps.

Checks in configurations only (see Key.DELAY_BETWEEN_STEPS).

runnerscriptpath()

Gives the path of the scenario runner script path.

Useful when executing campaigns.

scenariotimeout()

Retrieves the maximum time for a scenario execution.

Useful when executing campaigns.

Checks in configurations only (see Key.SCENARIO_TIMEOUT).

resultsextrainfo()

Retrieves the list of scenario attributes to display for extra info when displaying test results.

Returns:

List of scenario attribute names.

Applicable when displaying campaign results or the result of several tests executed in a single command line.

loadissuelevelnames()

Loads the issue level names configured through configuration files.

issuelevelerror()

Retrieves the issue level from and above which known issues should be considered as errors.

Returns:

Error issue level if set, None otherwise.

issuelevelignored()

Retrieves the issue level from and under which known issues should be ignored.

Returns:

Ignored issue level if set, None otherwise.

_readstringlistfromconf(config_key, outlist)

Reads a string list from the configuration database, and feeds an output list.

Parameters:
  • config_key

    Configuration key for the string list.

    The configuration node pointed by config_key may be either a list of strings, or a comma-separated string.

  • outlist

    Output string list to feed.

    Values are prevented in case of duplicates.

_warning(node, msg)

Logs a warning message for the given configuration node.

Parameters:
  • node – Configuration node related to the warning.

  • msg – Warning message.

ScenarioConfigKey

alias of Key