cloner.detector_run
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
@@ -495,3 +495,31 @@ def test_detector_enabled(cloner_dir_with_config):
|
||||
assert not cl.detector_enabled
|
||||
Path(cloner_dir_with_config).joinpath("config", "detector.cfg").touch()
|
||||
assert cl.detector_enabled
|
||||
|
||||
|
||||
def test_detector_run(cloner_dir_with_config):
|
||||
called = False
|
||||
|
||||
def callback_test(commit):
|
||||
nonlocal called
|
||||
called = True
|
||||
|
||||
def run_mock(callback):
|
||||
callback("Anything")
|
||||
|
||||
ds = MockDirStruct(cloner_dir_with_config)
|
||||
ds.config.cloner_repo_url = "https://mock"
|
||||
|
||||
mocks = {
|
||||
'check_fingerprint': MagicMock(side_effect = [False, True]),
|
||||
'run': MagicMock(side_effect = run_mock),
|
||||
}
|
||||
|
||||
with patch.multiple('repo_cloner.lib.cloner.Detector', **mocks):
|
||||
cl = Cloner(ds)
|
||||
cl.detector_run(callback_test)
|
||||
assert not repo_cloner.lib.cloner.Detector.run.called
|
||||
assert not called
|
||||
cl.detector_run(callback_test)
|
||||
assert repo_cloner.lib.cloner.Detector.run.called
|
||||
assert called
|
||||
|
||||
Reference in New Issue
Block a user