avocado_i2n.params_parser module¶
Module for handling all Cartesian config parsing and making it reusable and maximally performant.
SUMMARY¶
Copyright: Intra2net AG
INTERFACE¶
- exception avocado_i2n.params_parser.EmptyCartesianProduct(message: str)[source]¶
Bases:
ExceptionEmpty Cartesian product of variants.
- avocado_i2n.params_parser.custom_configs_dir() str[source]¶
Get custom directory for all config files.
- avocado_i2n.params_parser.tests_ovrwrt_file() str[source]¶
Get overwrite file for all tests (nodes).
- avocado_i2n.params_parser.vms_ovrwrt_file() str[source]¶
Get overwrite file for all vms (a category of objects).
- avocado_i2n.params_parser.ovrwrt_file(category: str) str[source]¶
Get overwrite file for all objects.
- class avocado_i2n.params_parser.ParsedContent(content: str)[source]¶
Bases:
objectClass for parsed content of a general type.
- class avocado_i2n.params_parser.ParsedFile(content: str)[source]¶
Bases:
ParsedContentClass for parsed content of file type.
- class avocado_i2n.params_parser.ParsedStr(content: str)[source]¶
Bases:
ParsedContentClass for parsed content of string type.
- class avocado_i2n.params_parser.ParsedDict(content: str)[source]¶
Bases:
ParsedContentClass for parsed content of dictionary type.
- class avocado_i2n.params_parser.Reparsable[source]¶
Bases:
objectClass to represent quickly parsable Cartesian configuration.
The class produces both parser and parameters (parser dicts) on demand.
- parse_next_file(pfile: str) None[source]¶
Add a file parsing step.
- Parameters:
pfile – file to be parsed next
If the parsable file has a relative form (not and absolute path), it will be searched in the relative test suite config directory.
- parse_next_str(pstring: str) None[source]¶
Add a string parsing step.
- Parameters:
pstring – string to be parsed next
- parse_next_dict(pdict: dict[str, str]) None[source]¶
Add a dictionary parsing step.
- Parameters:
pdict – dictionary to be parsed next
- parse_next_batch(base_file: str = None, base_str: str | None = '', base_dict: dict[str, str] = None, ovrwrt_file: str = None, ovrwrt_str: str | None = '', ovrwrt_dict: dict[str, str] = None) None[source]¶
Parse a batch of base file, string, and dictionary.
Possibly also parse a batch of an overwrite file (with custom parameters at the user’s home location).
- Parameters:
base_file – file to be parsed first
base_str – string to be parsed first
base_dict – params to be added first
ovrwrt_file – file to be parsed last
ovrwrt_str – string to be parsed last
ovrwrt_dict – params to be added last
The priority of the setting follows the order of the arguments: Dictionary with some parameters is topmost, string with some parameters is next and the file with parameters is taken as a base. The overwriting version is taken last, the base version first.
- avocado_i2n.params_parser.all_restrictions() list[str][source]¶
Return all restrictions that can be passed for any test configuration.
- Returns:
all available (from configuration) vms
- avocado_i2n.params_parser.all_objects(key: str = 'vms', composites: list[str] = None) list[str][source]¶
Return all test objects that can be passed for any test configuration.
- Param:
key: key to extract parametric objects from
- Parameters:
composites – composite restriction of the returned objects
- Returns:
all available (from configuration) objects of a given type
- avocado_i2n.params_parser.all_suffixes_by_restriction(restriction: str, key: str = 'nets') list[str][source]¶
Return all object suffixes via restriction of their variants.
- Param:
restriction: restriction of the suffix variants
- Param:
key: key to describe the parametric object type
- Returns:
all restricted (from configuration) object suffixes of a given type
- avocado_i2n.params_parser.main_vm() str | None[source]¶
Return the default main vm that can be passed for any test configuration.
- Returns:
main available (from configuration) vm
- avocado_i2n.params_parser.re_str(variant_str: str, base_str: str = '', tag: str = '') str[source]¶
Add a variant restriction to the base string, optionally adding a custom tag as well.
- Parameters:
variant_str – variant restriction
base_str – string where the variant restriction will be added
tag – additional tag to the variant combination
- Returns:
restricted parameter string
- avocado_i2n.params_parser.join_str(variant_strs: dict[str, str], sort_key: str, base_str: str = '') str[source]¶
Join all object variant restrictions over the base string.
- Parameters:
variant_strs – variant restrictions for each object as key, value pair
sort_key – key to extract parametric objects from
base_str – string where the variant restriction will be added
- Returns:
restricted parameter string