Skip to content

Constants

Soft coded centalized constants

get_province_names()

HACK to make it possible for pytest to generate a smaller network

Raises:

Type Description
ValueError

if the PROV_NAMES is not a list or str

Returns:

Name Type Description
list list

the province node names to build the network

Source code in workflow/scripts/constants.py
def get_province_names() -> list:
    """HACK to make it possible for pytest to generate a smaller network

    Raises:
        ValueError: if the PROV_NAMES is not a list or str

    Returns:
        list: the province node names to build the network
    """
    default_prov_names = list(REGIONAL_GEO_TIMEZONES_DEFAULT)
    _provs = os.getenv("PROV_NAMES", default_prov_names)
    if isinstance(_provs, str):
        _provs = re.findall(r"[\w']+", _provs)
        if not _provs:
            xpected = '["region1", ...]'
            err = f"Environment var PROV_NAMES {_provs} for tests did not have expected format: "
            raise ValueError(err + xpected)
    elif not isinstance(_provs, list):
        raise ValueError("PROV_NAMES must be a list or str")
    return _provs