X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=e0aa864a25deead733a3300a940930ada355e239;hb=ed4e48f967b1fccdd3fb142c0a166ee04ad6c2b0;hp=2a1cc5530a2b7c6d5460047b2925371512425aa7;hpb=48d35093a120d5a8c02a28c4a72f4f7d69b664f4;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index 2a1cc55..e0aa864 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -44,8 +44,7 @@ import os import re import time -from preload.model import create_preloads -from config import get_generator_plugin_names +from preload.engine import PLUGIN_MGR, create_preloads from tests.helpers import get_output_dir try: @@ -348,7 +347,11 @@ def pytest_sessionfinish(session, exitstatus): def pytest_terminal_summary(terminalreporter, exitstatus): # Ensures all preload information and warnings appear after # test results - create_preloads(terminalreporter.config, exitstatus) + try: + create_preloads(terminalreporter.config, exitstatus) + except Exception: + print("Error creating preloads, skipping preload generation") + traceback.print_exc() # noinspection PyUnusedLocal @@ -360,13 +363,9 @@ def pytest_collection_modifyitems(session, config, items): config.traceability_items = list(items) # save all items for traceability if not config.option.self_test: for item in items: + passed_categories = set(config.option.test_categories or []) all_of_categories = getattr(item.function, "all_categories", set()) any_of_categories = getattr(item.function, "any_categories", set()) - if any_of_categories and all_of_categories: - raise RuntimeError( - "categories can not use 'any_of' with other categories" - ) - passed_categories = set(config.option.test_categories or []) if all_of_categories and not all_of_categories.issubset(passed_categories): item.add_marker( pytest.mark.skip( @@ -375,7 +374,7 @@ def pytest_collection_modifyitems(session, config, items): ) ) ) - elif any_of_categories and not passed_categories.intersection( + if any_of_categories and not passed_categories.intersection( any_of_categories ): item.add_marker( @@ -829,13 +828,6 @@ def pytest_addoption(parser): help="optional category of test to execute", ) - parser.addoption( - "--env-directory", - dest="env_dir", - action="store", - help="optional directory of .env files for preload generation", - ) - parser.addoption( "--preload-format", dest="preload_formats", @@ -843,7 +835,24 @@ def pytest_addoption(parser): help=( "Preload format to create (multiple allowed). If not provided " "then all available formats will be created: {}" - ).format(", ".join(get_generator_plugin_names())), + ).format(", ".join(g.format_name() for g in PLUGIN_MGR.preload_generators)), + ) + + parser.addoption( + "--preload-source-type", + dest="preload_source_type", + action="store", + default="envfiles", + help=( + "Preload source type to create (multiple allowed): {}" + ).format(", ".join(s.get_identifier() for s in PLUGIN_MGR.preload_sources)), + ) + + parser.addoption( + "--preload-source", + dest="preload_source", + action="store", + help="File or directory containing the source dat for the preloads", ) @@ -859,7 +868,8 @@ def pytest_configure(config): or config.getoption("self_test") or config.getoption("help") ): - raise Exception('One of "--template-dir" or' ' "--self-test" must be specified') + raise Exception('One of "--template-directory" or' + ' "--self-test" must be specified') def pytest_generate_tests(metafunc):