onyo.conftest module
- class onyo.conftest.AnnotatedGitRepo(path, find_root=False)[source]
Bases:
GitRepoAnnotate a
GitRepoobject to ease testing.Populated files and directories are stored in
.test_annotation.- __init__(path, find_root=False)[source]
Instantiate an
AnnotatedGitRepoobject withpathas the root directory.- Parameters:
path (
Path) – Absolute Path of a git repository.find_root (
bool(default:False)) – Replacepathwith the results ofonyo.lib.git.GitRepo.find_root(). Thus any directory of a git repository can be passed aspath, not just the repo root.
- class onyo.conftest.AnnotatedOnyoRepo(path, init=False, find_root=False)[source]
Bases:
OnyoRepoAnnotate an
OnyoRepoobject to ease testing.Populated inventory items are stored in
.test_annotation.- __init__(path, init=False, find_root=False)[source]
Instantiate an
AnnotatedOnyoRepoobject withpathas the root directory.- Parameters:
path (
Path) – Absolute path to the root of the Onyo Repository.init (
bool(default:False)) – Initializepathas a git repo and create/populate the subdir.onyo/. Cannot be used withfind_root=True.find_root (
bool(default:False)) – Replacepathwith the results ofonyo.lib.onyo.OnyoRepo.find_root(). Thus any directory of a git repository can be passed aspath, not just the repo root. Cannot be used withinit==True.
- class onyo.conftest.Helpers[source]
Bases:
objectA collection of helper utilities for tests.
- static flatten(xs)[source]
Yield a flattened Iterable.
Flatten a multidimensional list into a single dimension.
- Return type:
- onyo.conftest.clean_env(request)[source]
Ensure that
$EDITORis unset.Makes sure that the
$EDITORenvironment variable is not inherited from the user environment nor other tests.- Return type:
- onyo.conftest.clean_locale(request)[source]
Ensure that the locale is set to ‘en_US.UTF-8’.
Tests that involve sorting can be impacted by the locale. This sets it to a known, static target.
- Return type:
- onyo.conftest.fake_class_scope()[source]
Scope the
fakeparameter fixture for classes.- Return type:
- onyo.conftest.fake_function_scope()[source]
Scope the
fakeparameter fixture for functions.- Return type:
- onyo.conftest.fake_module_scope()[source]
Scope the
fakeparameter fixture for modules.- Return type:
- onyo.conftest.fake_session_scope()[source]
Scope the
fakeparameter fixture for sessions.- Return type:
- onyo.conftest.fixture_fake()[source]
Yield a Faker object with the Onyo provider loaded.
See also
- Return type:
- onyo.conftest.fixture_gitrepo(tmp_path, request)[source]
Yield an AnnotatedGitRepo object, populated from fixtures.
A fresh repository is created in a unique temporary directory. It is populated via the following marker (which is then stored in
.test_annotationfor later reference by tests):gitrepo_contents()
Parent directories of all items are automatically created.
Example markers:
gitrepo_contents((Path('.gitignore'), "dir_to_ignore/"), (Path("dir_to_ignore/some.pdf"), "0xDEADBEEF"), (Path("a/b/c/"), ""), (Path("1/2/3/"), ""), )
Example annotations:
for dir_path in onyorepo.test_annotation['directories']: assert dir_path.is_dir() is True
- Return type:
- onyo.conftest.fixture_helpers()[source]
Return a Helper object with various helper utilities.
See also
- onyo.conftest.fixture_inventory(repo)[source]
Yield a populated Inventory object.
The inventory is populated with the following directories:
different/place/
empty/
somewhere/nested/
And the following asset:
somewhere/nested/TYPE_MAKER_MODEL.SERIAL
- onyo.conftest.fixture_onyorepo(gitrepo, request)[source]
Yield an AnnotatedOnyoRepo object, populated from fixtures.
A fresh repository is created in a unique temporary directory. It is populated via these markers (which are then stored in
.test_annotationfor later reference by tests):inventory_assets()inventory_dirs()inventory_templates()
Parent directories of all items are automatically created.
Example markers:
inventory_assets() inventory_assets(Item(type="type", make="make", model="model", serial=1, onyo.path.parent=Path("here/")), Item(type="type", make="make", model="model", serial=2, onyo.path.parent=Path("there/")), ) inventory_dirs(Path('a/b/c/'), Path('1/2/3/'), ) inventory_templates() inventory_templates((onyo.lib.consts.TEMPLATE_DIR / "generic" / "laptop", "---\ntype: laptop\n"), (onyo.lib.consts.TEMPLATE_DIR / "generic" / "display", "---\ntype: display\n"), )
Example annotations:
for asset_path in onyorepo.test_annotation['assets']: assert onyorepo.is_asset_path(asset_path) is True
- Return type:
- onyo.conftest.fixture_repo(tmp_path, request)[source]
Yield an OnyoRepo object, populated from fixtures.
A fresh repository is created in a unique temporary directory. It is then populated via these markers:
repo_dirs()repo_files()(parent directories of files are automatically created)
Example:
repo_dirs("a/b/c", "1/2/3") repo_files("here/type_make_model.1", "there/type_make_model.2")
- onyo.conftest.fixture_ui(request)[source]
Configure
onyo.lib.ui.UI.Applies values from a dict defined by the
uimarker.Supported keys are:
'yes','quiet', and'debug'. All accept booleans.See also
- Return type:
- onyo.conftest.gitrepo_class_scope(tmp_path_class_scope, request)[source]
Scope the
gitrepoparameter fixture for classes.- Return type:
- onyo.conftest.gitrepo_function_scope(tmp_path, request)[source]
Scope the
gitrepoparameter fixture for functions.- Return type:
- onyo.conftest.gitrepo_module_scope(tmp_path_module_scope, request)[source]
Scope the
gitrepoparameter fixture for modules.- Return type:
- onyo.conftest.gitrepo_session_scope(tmp_path, request)[source]
Scope the
gitrepoparameter fixture for sessions.- Return type:
- onyo.conftest.helpers_class_scope()[source]
Scope the
helpersparameter fixture for classes.- Return type:
- onyo.conftest.helpers_function_scope()[source]
Scope the
helpersparameter fixture for functions.- Return type:
- onyo.conftest.helpers_module_scope()[source]
Scope the
helpersparameter fixture for modules.- Return type:
- onyo.conftest.helpers_session_scope()[source]
Scope the
helpersparameter fixture for sessions.- Return type:
- onyo.conftest.inventory_class_scope(repo_class_scope)[source]
Scope the
inventoryparameter fixture for classes.- Return type:
- onyo.conftest.inventory_function_scope(repo)[source]
Scope the
inventoryparameter fixture for functions.- Return type:
- onyo.conftest.inventory_module_scope(repo_module_scope)[source]
Scope the
inventoryparameter fixture for modules.- Return type:
- onyo.conftest.inventory_session_scope(repo_session_scope)[source]
Scope the
inventoryparameter fixture for sessions.- Return type:
- onyo.conftest.onyorepo_class_scope(gitrepo_class_scope, request)[source]
Scope the
onyorepoparameter fixture for classes.- Return type:
- onyo.conftest.onyorepo_function_scope(gitrepo, request)[source]
Scope the
onyorepoparameter fixture for functions.- Return type:
- onyo.conftest.onyorepo_module_scope(gitrepo_module_scope, request)[source]
Scope the
onyorepoparameter fixture for modules.- Return type:
- onyo.conftest.onyorepo_session_scope(gitrepo_session_scope, request)[source]
Scope the
onyorepoparameter fixture for sessions.- Return type:
- onyo.conftest.params(d)[source]
Parameterize a dictionary with human-friendly names.
Allows for meaningful variant names to be printed to the CLI when <variable> is not easily string-ify-able.
For example, to run tests with a variable
variantwith the value<variable>and<id>as the test ID:{ "<id>": {"variant": <variable>}, ... }
- Return type:
MarkDecorator
- onyo.conftest.repo_class_scope(tmp_path_class_scope, request)[source]
Scope the
repoparameter fixture for classes.- Return type:
- onyo.conftest.repo_function_scope(tmp_path, request)[source]
Scope the
repoparameter fixture for functions.- Return type:
- onyo.conftest.repo_module_scope(tmp_path_module_scope, request)[source]
Scope the
repoparameter fixture for modules.- Return type:
- onyo.conftest.repo_session_scope(tmp_path_session_scope, request)[source]
Scope the
repoparameter fixture for sessions.- Return type:
- onyo.conftest.tmp_path_class_scope(tmp_path_factory, request)[source]
Scope the
tmp_pathparameter fixture for classes.
- onyo.conftest.tmp_path_module_scope(tmp_path_factory, request)[source]
Scope the
tmp_pathparameter fixture for modules.
- onyo.conftest.tmp_path_session_scope(tmp_path_factory, request)[source]
Scope the
tmp_pathparameter fixture for sessions.