Tests: test cloner.sync for failed main repo

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
Václav Valíček 2022-08-02 23:29:18 +02:00
parent 1f06d38f49
commit b6b5b8b8ca
Signed by: valicek
GPG Key ID: FF05BDCA0C73BB31

View File

@ -262,6 +262,26 @@ def test_sync(cloner_dir_struct, tmp_path, monkeypatch):
assert not c.sync() assert not c.sync()
def test_sync_submodules_failed(cloner_dir_with_config, caplog):
ds = MockDirStruct(cloner_dir_with_config)
# mock config for submodules
ds.config.cloner_submodules = True
ds.config.cloner_repo_url = "asdhlk"
# mock repo_tool.fetch to return false
mocks = {
'initialized': PropertyMock(return_value = True),
'fetch': MagicMock(return_value = False)
}
with patch.multiple("repo_cloner.lib.cloner.RepoTool", **mocks) as mock:
cl = Cloner(ds)
assert not cl.sync()
assert caplog.records[1].levelname == "CRITICAL"
assert caplog.records[1].message == "Repo fetch failed for Mocked Project"
def test_perform_check(cloner_dir_with_config, monkeypatch, caplog): def test_perform_check(cloner_dir_with_config, monkeypatch, caplog):
call_counter: int = 0 call_counter: int = 0