Test Catalog
AntaCatalog ¶
AntaCatalog(tests: list[AntaTestDefinition] | None = None, filename: str | Path | None = None)
Class representing an ANTA Catalog.
It can be instantiated using its contructor or one of the static methods: parse()
, from_list()
or from_dict()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tests |
list[AntaTestDefinition] | None
|
A list of AntaTestDefinition instances. |
None
|
filename |
str | Path | None
|
The path from which the catalog is loaded. |
None
|
Source code in anta/catalog.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
tests
property
writable
¶
tests: list[AntaTestDefinition]
List of AntaTestDefinition in this catalog
from_dict
staticmethod
¶
from_dict(data: RawCatalogInput, filename: str | Path | None = None) -> AntaCatalog
Create an AntaCatalog instance from a dictionary data structure.
See RawCatalogInput type alias for details.
It is the data structure returned by yaml.load()
function of a valid
YAML Test Catalog file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
RawCatalogInput
|
Python dictionary used to instantiate the AntaCatalog instance |
required |
filename |
str | Path | None
|
value to be set as AntaCatalog instance attribute |
None
|
Source code in anta/catalog.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
from_list
staticmethod
¶
from_list(data: ListAntaTestTuples) -> AntaCatalog
Create an AntaCatalog instance from a list data structure. See ListAntaTestTuples type alias for details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ListAntaTestTuples
|
Python list used to instantiate the AntaCatalog instance |
required |
Source code in anta/catalog.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
get_tests_by_tags ¶
get_tests_by_tags(tags: list[str], strict: bool = False) -> list[AntaTestDefinition]
Return all the tests that have matching tags in their input filters. If strict=True, returns only tests that match all the tags provided as input. If strict=False, return all the tests that match at least one tag provided as input.
Source code in anta/catalog.py
280 281 282 283 284 285 286 287 288 289 290 291 |
|
parse
staticmethod
¶
parse(filename: str | Path) -> AntaCatalog
Create an AntaCatalog instance from a test catalog file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str | Path
|
Path to test catalog YAML file |
required |
Source code in anta/catalog.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
AntaTestDefinition ¶
AntaTestDefinition(**data: Any)
Bases: BaseModel
Define a test with its associated inputs.
test: An AntaTest concrete subclass inputs: The associated AntaTest.Input subclass instance
Source code in anta/catalog.py
45 46 47 48 49 50 51 52 53 54 55 |
|
check_inputs ¶
check_inputs() -> 'AntaTestDefinition'
The inputs
class attribute needs to be an instance of the AntaTest.Input subclass defined in the class test
.
Source code in anta/catalog.py
81 82 83 84 85 86 87 88 |
|
instantiate_inputs
classmethod
¶
instantiate_inputs(data: AntaTest.Input | dict[str, Any] | None, info: ValidationInfo) -> AntaTest.Input
If the test has no inputs, allow the user to omit providing the inputs
field.
If the test has inputs, allow the user to provide a valid dictionary of the input fields.
This model validator will instantiate an Input class from the test
class field.
Source code in anta/catalog.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
AntaCatalogFile ¶
Bases: RootModel[Dict[ImportString[Any], List[AntaTestDefinition]]]
This model represents an ANTA Test Catalog File.
A valid test catalog file must have the following structure:
check_tests
classmethod
¶
check_tests(data: Any) -> Any
Allow the user to provide a Python data structure that only has string values. This validator will try to flatten and import Python modules, check if the tests classes are actually defined in their respective Python module and instantiate Input instances with provided value to validate test inputs.
Source code in anta/catalog.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|