def test_not_skipped_test_playbook_for_dynamic_section(mocker, conf_data, yml_data): """ Given: - Script data. - Conf JSON file. When: - running is_valid_file_in_conf_json specifically on the content entity with dynamic section tag. Cases: Case 1) Has not skipped TPB. Case 2) Has skipped TPB. Case 3) Does not have TPB. Then: - Ensure True is returned. """ mocker.patch.object(ConfJsonValidator, 'load_conf_file', return_value=conf_data) validator = ConfJsonValidator() assert validator.is_valid_file_in_conf_json(current_file=yml_data, file_type=FileType.SCRIPT, file_path="SomeFilePath")
def test_integration_has_unskipped_test_playbook(mocker, conf_dict, answer): """ Given: - An integration. - conf file with configurations for the integration. When: running is_valid_file_in_conf_json specifically on integration. Then: Validate the integration has at least one unskipped test playbook. """ mocker.patch.object(ConfJsonValidator, 'load_conf_file', return_value=conf_dict) validator = ConfJsonValidator() current = { "commonfields": { "id": "SomeIntegration" }, "tests": ["SomeTestPlaybook"] } assert validator.is_valid_file_in_conf_json( current_file=current, file_type=FileType.INTEGRATION, file_path="SomeFilePath") is answer
def test_script_has_unskipped_test_playbook(mocker, test_playbooks, conf_dict, answer): """ Given: - A Script. - conf file with skipped tests. When: running is_valid_file_in_conf_json specifically on the script. Then: Validate the script has at least one unskipped test playbook. """ mocker.patch.object(ConfJsonValidator, 'load_conf_file', return_value=conf_dict) validator = ConfJsonValidator() current = {"commonfields": {"id": "SomeScript"}, "tests": test_playbooks} assert validator.is_valid_file_in_conf_json( current_file=current, file_type=FileType.SCRIPT, file_path="SomeFilePath") is answer
def test_non_testable_entity_is_vaild_in_conf(mocker): """ Given: - A content entity that cant have test playbooks, specifically a test playbook - Some conf file. When: running is_valid_file_in_conf_json specifically on the content entity. Then: Validate the content entity is valid in conf file. """ mocker.patch.object( ConfJsonValidator, 'load_conf_file', return_value={"skipped_tests": { "SomeTestPlaybook": "Some Issue" }}) validator = ConfJsonValidator() current = {"id": "TheTestPlaybook"} assert validator.is_valid_file_in_conf_json( current_file=current, file_type=FileType.TEST_PLAYBOOK, file_path="SomeFilePath")