def test_check_discovery__members_not_functions(settings): check_modules = ("members_not_functions", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules uut.discover_checks() from zoo.auditing.check_discovery import KINDS, CHECKS assert len(CHECKS) == 4 assert {function.__name__ for function in CHECKS} == { "check_another_dummy_function", "check_dummy_function", } for function in CHECKS: assert function() == (function.__name__ == "check_dummy_function") assert len(KINDS) == 2 assert set(KINDS.keys()) == { "something:check_dummy_function", "something:check_another_dummy_function", }
def test_check_discovery__correct_modules(settings): check_modules = ("correct_first_module", "correct_second_module") settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules uut.discover_checks() from zoo.auditing.check_discovery import KINDS, CHECKS, PATCHES assert len(CHECKS) == 10 assert {function.__name__ for function in CHECKS} == { "check_another_dummy_function", "check_dummy_function", } for function in CHECKS: assert function() == (function.__name__ == "check_dummy_function") assert len(KINDS) == 2 assert set(KINDS.keys()) == { "something:check_dummy_function", "something:check_another_dummy_function", } assert len(PATCHES) == 1 assert set(PATCHES.keys()) == {"something:check_dummy_function"} assert KINDS["something:check_dummy_function"].apply_patch() is True
def test_check_discovery__incorrect_metadata(settings): check_modules = ("incorrect_metadata", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules with pytest.raises(uut.IncorrectCheckMetadataError): uut.discover_checks()
def test_check_discovery__missing_metadata(settings): check_modules = ("missing_metadata", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules with pytest.raises(FileNotFoundError): uut.discover_checks()
def test_check_discovery__non_existing_module(settings): check_modules = ("non_existing_module", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules with pytest.raises(ModuleNotFoundError): uut.discover_checks()
def test_check_discovery__incorrect_module(settings): check_modules = ("incorrect_module", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules uut.discover_checks() from zoo.auditing.check_discovery import CHECKS assert len(CHECKS) == 0
def test_check_discovery__only_folders_module(settings): check_modules = ("only_folders", ) settings.ZOO_AUDITING_ROOT = Path(f"{test_folder_dir}/tasks") settings.ZOO_AUDITING_CHECKS = check_modules uut.discover_checks() from zoo.auditing.check_discovery import CHECKS assert len(CHECKS) == 4 assert {function.__name__ for function in CHECKS} == { "check_another_dummy_function", "check_dummy_function", } for function in CHECKS: assert function() == (function.__name__ == "check_dummy_function")