calico.base

Base classes for Calico.

class calico.base.Action(type_, data, timeout=-1)

An action in a test script.

Parameters:
  • type (ActionType) – Expect or send.
  • data (str) – Data to expect or send.
  • timeout (Optional[int]) – Timeout duration, in seconds.
data = None

Data description of this action, what to expect or send.

timeout = None

Timeout duration of this action.

type_ = None

Type of this action, expect or send.

class calico.base.ActionType

Type of an action.

class calico.base.Calico

A suite containing a collection of ordered test cases.

add_case(case)

Add a test case to this suite.

Parameters:case – Test case to add.
points = None

Total points in this test suite.

run(tests=None, quiet=False, g_timeout=None)

Run this test suite.

Parameters:
  • tests – Tests to include in the run.
  • quiet – Whether to suppress progress messages.
  • g_timeout – Global timeout value for the all tests
Return type:

Mapping[str, Any]

Returns:

A report containing the results.

class calico.base.TestCase(name, command, timeout=-1, exits=0, points=None, blocker=False, visible=True)

A case in a test suite.

Parameters:
  • name (str) – Name of the case.
  • command (str) – Command to run.
  • timeout (Optional[int]) – Timeout duration, in seconds.
  • exits (Optional[int]) – Expected exit status.
  • points (Optional[Union[int, float]]) – Contribution to overall points.
  • blocker (Optional[bool]) – Whether failure blocks subsequent cases.
  • visible (Optional[bool]) – Whether the test will be visible during the run.
add_action(action)

Append an action to the script of this test case.

Parameters:action – Action to append to the script.
blocker = None

Whether failure in this case will block subsequent cases or not.

command = None

Command to run in this test case.

exits = None

Expected exit status of this test case.

name = None

Name of this test case.

points = None

How much this test case contributes to the total points.

run(defs=None, jailed=False, g_timeout=None)

Run this test and produce a report.

Parameters:
  • defs – Variable substitutions.
  • jailed – Whether to jail the command to the current directory.
  • g_timeout – Global timeout for all expects in the test
Return type:

Mapping[str, Union[str, List[str]]]

Returns:

Result report of the test.

script = None

Sequence of actions to run in this test case.

timeout = None

Timeout duration of this test case, in seconds.

visible = None

Whether this test will be visible during the run or not.

calico.base.run_script(command, script, defs=None, g_timeout=None)

Run a command and check whether it follows a script.

Parameters:
  • command (str) – Command to run.
  • script (List[Action]) – Script to check against.
  • defs (Optional[Mapping]) – Variable substitutions.
  • g_timeout (Optional[int]) – Global timeout value for the spawn class
Return type:

Tuple[int, List[str]]

Returns:

Exit status and errors.