Skip to content

Result Manager models

Test Result model

TestResult UML model

TestResult

Bases: BaseModel

Describe the result of a test from a single device.

Attributes:

Name Type Description
name str

Name of the device where the test was run.

test str

Name of the test run on the device.

categories list[str]

List of categories the TestResult belongs to. Defaults to the AntaTest categories.

description str

Description of the TestResult. Defaults to the AntaTest description.

result AntaTestStatus

Result of the test. Must be one of the AntaTestStatus Enum values: unset, success, failure, error or skipped.

messages list[str]

Messages to report after the test, if any.

custom_field str | None

Custom field to store a string for flexibility in integrating with ANTA.

is_error

is_error(message: str | None = None) -> None

Set status to error.

Parameters:

Name Type Description Default
message str | None

Optional message related to the test.

None
Source code in anta/result_manager/models.py
 94
 95
 96
 97
 98
 99
100
101
102
103
def is_error(self, message: str | None = None) -> None:
    """Set status to error.

    Parameters
    ----------
    message
        Optional message related to the test.

    """
    self._set_status(AntaTestStatus.ERROR, message)

is_failure

is_failure(message: str | None = None) -> None

Set status to failure.

Parameters:

Name Type Description Default
message str | None

Optional message related to the test.

None
Source code in anta/result_manager/models.py
72
73
74
75
76
77
78
79
80
81
def is_failure(self, message: str | None = None) -> None:
    """Set status to failure.

    Parameters
    ----------
    message
        Optional message related to the test.

    """
    self._set_status(AntaTestStatus.FAILURE, message)

is_skipped

is_skipped(message: str | None = None) -> None

Set status to skipped.

Parameters:

Name Type Description Default
message str | None

Optional message related to the test.

None
Source code in anta/result_manager/models.py
83
84
85
86
87
88
89
90
91
92
def is_skipped(self, message: str | None = None) -> None:
    """Set status to skipped.

    Parameters
    ----------
    message
        Optional message related to the test.

    """
    self._set_status(AntaTestStatus.SKIPPED, message)

is_success

is_success(message: str | None = None) -> None

Set status to success.

Parameters:

Name Type Description Default
message str | None

Optional message related to the test.

None
Source code in anta/result_manager/models.py
61
62
63
64
65
66
67
68
69
70
def is_success(self, message: str | None = None) -> None:
    """Set status to success.

    Parameters
    ----------
    message
        Optional message related to the test.

    """
    self._set_status(AntaTestStatus.SUCCESS, message)