def test_perfdocs_verifier_missing_contents_in_suite(logger, structured_logger, perfdocs_sample): top_dir = perfdocs_sample["top_dir"] setup_sample_logger(logger, structured_logger, top_dir) with open(perfdocs_sample["config"], "r") as file: filedata = file.read() filedata = filedata.replace("suite:", "InvalidSuite:") with open(perfdocs_sample["config"], "w") as file: file.write(filedata) from perfdocs.verifier import Verifier verifier = Verifier(top_dir) verifier._check_framework_descriptions(verifier._gatherer.perfdocs_tree[0]) expected = ( "Could not find an existing suite for InvalidSuite - bad suite name?", "Missing suite description for suite", ) assert logger.warning.call_count == 2 for i, call in enumerate(logger.warning.call_args_list): args, _ = call assert args[0] == expected[i]
def test_perfdocs_verifier_not_existing_tests_in_suites( logger, structured_logger, perfdocs_sample): top_dir = perfdocs_sample["top_dir"] setup_sample_logger(logger, structured_logger, top_dir) with open(perfdocs_sample["config"], "r") as file: filedata = file.read() filedata = filedata.replace("Example", "DifferentName") with open(perfdocs_sample["config"], "w") as file: file.write(filedata) from perfdocs.verifier import Verifier verifier = Verifier(top_dir) verifier._check_framework_descriptions(verifier._gatherer.perfdocs_tree[0]) expected = [ "Could not find an existing test for DifferentName - bad test name?", "Could not find a test description for Example", ] assert logger.warning.call_count == 2 for i, call in enumerate(logger.warning.call_args_list): args, _ = call assert args[0] == expected[i]
def test_perfdocs_verifier_validate_descriptions_pass(logger, structured_logger, perfdocs_sample): top_dir = perfdocs_sample["top_dir"] setup_sample_logger(logger, structured_logger, top_dir) from perfdocs.verifier import Verifier verifier = Verifier(top_dir) verifier._check_framework_descriptions(verifier._gatherer.perfdocs_tree[0]) assert logger.warning.call_count == 0 assert logger.log.call_count == 1 assert len(logger.mock_calls) == 1
def test_perfdocs_verifier_not_existing_suite_in_test_list( logger, structured_logger, perfdocs_sample): top_dir = perfdocs_sample["top_dir"] manifest_path = perfdocs_sample["manifest"] setup_sample_logger(logger, structured_logger, top_dir) from perfdocs.verifier import Verifier verifier = Verifier(top_dir) os.remove(manifest_path) verifier._check_framework_descriptions(verifier._gatherer.perfdocs_tree[0]) expected = ( "Could not find an existing suite for suite - bad suite name?", perfdocs_sample["config"], ) args, _ = logger.warning.call_args assert logger.warning.call_count == 1 assert args == expected