Skip to content

Commit edaef54

Browse files
Vladimir Kotalahornace
authored andcommitted
parametrize further
1 parent d989c5e commit edaef54

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tools/src/test/python/test_mirror.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import pytest
3232
import requests
33-
from mockito import verify, patch, spy2, mock, ANY, when
33+
from mockito import verify, patch, spy2, mock, ANY, when, unstub
3434

3535
import opengrok_tools.mirror
3636
from conftest import posix_only, system_binary
@@ -240,7 +240,8 @@ def test_disabled_command_run():
240240

241241

242242
@pytest.mark.parametrize("hook_type", [HOOK_PRE_PROPERTY, HOOK_POST_PROPERTY])
243-
def test_ignore_errors(monkeypatch, hook_type):
243+
@pytest.mark.parametrize("per_project", [True, False])
244+
def test_ignore_errors(monkeypatch, hook_type, per_project):
244245
"""
245246
Test that per project ignore errors property overrides failed hook.
246247
"""
@@ -252,13 +253,22 @@ def mock_get_repos(*args, **kwargs):
252253
project_name = "foo"
253254
hook_dir = "/befelemepeseveze"
254255
hook_name = "nonexistent"
255-
config = {
256-
HOOKDIR_PROPERTY: hook_dir,
257-
PROJECTS_PROPERTY: {
258-
project_name: {IGNORE_ERR_PROPERTY: True,
259-
HOOKS_PROPERTY: {hook_type: hook_name}}
256+
if per_project:
257+
config = {
258+
HOOKDIR_PROPERTY: hook_dir,
259+
PROJECTS_PROPERTY: {
260+
project_name: {IGNORE_ERR_PROPERTY: True,
261+
HOOKS_PROPERTY: {hook_type: hook_name}}
262+
}
263+
}
264+
else:
265+
config = {
266+
IGNORE_ERR_PROPERTY: True,
267+
HOOKDIR_PROPERTY: hook_dir,
268+
PROJECTS_PROPERTY: {
269+
project_name: {HOOKS_PROPERTY: {hook_type: hook_name}}
270+
}
260271
}
261-
}
262272

263273
with monkeypatch.context() as m:
264274
mock_get_repos.called = False
@@ -271,6 +281,9 @@ def mock_get_repos(*args, **kwargs):
271281
verify(opengrok_tools.utils.mirror).\
272282
process_hook(hook_type, os.path.join(hook_dir, hook_name),
273283
src_root, project_name, None, None)
284+
# Necessary to disable the process_hook spy otherwise mockito will
285+
# complain about recursive invocation.
286+
unstub()
274287

275288

276289
def test_disabled_command_run_args():

0 commit comments

Comments
 (0)