def test_context_only_runs_once_when_error_exist(mocker, integration, errors_found, errors_ignore, expected): """ Given - README that contains changes and YML file When - Run validate on README file and YML Then - Ensure validation only run once, either for YML or for README """ readme_validator = ReadMeValidator(FAKE_INTEGRATION_README) mocker.patch.object(ReadMeValidator, '_get_error_lists', return_value=(errors_found, errors_ignore)) result = readme_validator.is_context_different_in_yml() assert result == expected
def test_context_difference_created_is_valid(mocker, difference_found, expected): """ Given - README that contains changes and YML file When - Run validate on README file and YML Then - Ensure the difference context is correct """ mocker.patch('demisto_sdk.commands.common.hook_validations.readme.compare_context_path_in_yml_and_readme', return_value=difference_found) readme_validator = ReadMeValidator(FAKE_INTEGRATION_README) handle_error_mock = mocker.patch.object(ReadMeValidator, 'handle_error') valid = readme_validator.is_context_different_in_yml() assert valid == expected if not valid: handle_error_mock.assert_called() else: handle_error_mock.assert_not_called()