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)

Bases: Exception

Empty Cartesian product of variants.

avocado_i2n.params_parser.custom_configs_dir() str

Get custom directory for all config files.

avocado_i2n.params_parser.tests_ovrwrt_file() str

Get overwrite file for all tests (nodes).

avocado_i2n.params_parser.vms_ovrwrt_file() str

Get overwrite file for all vms (a category of objects).

avocado_i2n.params_parser.ovrwrt_file(category: str) str

Get overwrite file for all objects.

class avocado_i2n.params_parser.ParsedContent(content: str)

Bases: object

Class for parsed content of a general type.

reportable_form() str

Get parsed content representation used in reports of parsing steps.

Returns:

resulting report-compatible string

Raises:

NotImlementedError as this is an abstract method

parsable_form() str

Convert parameter content into parsable string.

Returns:

resulting parsable string

Raises:

NotImlementedError as this is an abstract method

class avocado_i2n.params_parser.ParsedFile(content: str)

Bases: ParsedContent

Class for parsed content of file type.

reportable_form() str

Get parsed file representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form() str

Convert parameter file name into parsable string.

Returns:

resulting parsable string

class avocado_i2n.params_parser.ParsedStr(content: str)

Bases: ParsedContent

Class for parsed content of string type.

reportable_form() str

Get parsed string representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form() str

Convert parameter string into parsable string.

Returns:

resulting parsable string

This is equivalent to the string since the string is parsable by definition.

class avocado_i2n.params_parser.ParsedDict(content: str)

Bases: ParsedContent

Class for parsed content of dictionary type.

reportable_form() str

Get parsed dictionary representation used in reports of parsing steps.

Arguments are identical to the ones of the parent class.

parsable_form() str

Convert parameter dictionary into parsable string.

Returns:

resulting parsable string

class avocado_i2n.params_parser.Reparsable

Bases: object

Class to represent quickly parsable Cartesian configuration.

The class produces both parser and parameters (parser dicts) on demand.

parse_next_file(pfile: str) None

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

Add a string parsing step.

Parameters:

pstring – string to be parsed next

parse_next_dict(pdict: dict[str, str]) None

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

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]

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]

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]

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

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

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

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