diff --git a/tests/test_cot_verify.py b/tests/test_cot_verify.py index 7a73354a..08c67ca7 100644 --- a/tests/test_cot_verify.py +++ b/tests/test_cot_verify.py @@ -1087,12 +1087,16 @@ async def fake_load(*args, **kwargs): ) @pytest.mark.asyncio async def test_populate_jsone_context_gecko_trees(mocker, chain, decision_link, action_link, cron_link, tasks_for, expected, raises): + async def get_project(*args, **kwargs): + return "mozilla-central" + async def get_scm_level(*args, **kwargs): return "1" async def get_pushlog_info(*args, **kwargs): return {"pushes": {1: {"user": "some-user", "date": 1500000000, "changesets": [{"desc": " ", "parents": ["baserev"]}]}}} + mocker.patch.object(cotverify, "get_project", get_project) mocker.patch.object(cotverify, "get_scm_level", get_scm_level) mocker.patch.object(cotverify, "get_pushlog_info", get_pushlog_info) mocker.patch.object(cotverify, "load_json_or_yaml", return_value={}) @@ -1149,7 +1153,12 @@ async def get_release_mock(release_name, *args, **kwargs): @pytest.mark.parametrize("has_triggered_by", (True, False)) @pytest.mark.asyncio -async def test_populate_jsone_context_git_cron(mobile_chain, mobile_cron_link, has_triggered_by): +async def test_populate_jsone_context_git_cron(mocker, mobile_chain, mobile_cron_link, has_triggered_by): + async def get_scm_level(*args, **kwargs): + return "3" + + mocker.patch.object(cotverify, "get_scm_level", get_scm_level) + if has_triggered_by: mobile_cron_link.task["payload"]["env"]["MOBILE_TRIGGERED_BY"] = "TaskclusterHook" diff --git a/tests/test_task.py b/tests/test_task.py index 121a521c..9e075288 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -246,6 +246,12 @@ def test_get_worker_type(task, result): @pytest.mark.asyncio async def test_get_project(context, mobile_context, source_url, expected, raises, context_type): context_ = mobile_context if context_type == "mobile" else context + context_.projects = { + "mozilla-central": {"repo": "https://hg.mozilla.org/mozilla-central", "repo_type": "hg", "access": "scm_level_3"}, + "mozilla-esr115": {"repo": "https://hg.mozilla.org/releases/mozilla-esr115", "repo_type": "hg", "access": "scm_level_3"}, + "try": {"repo": "https://hg.mozilla.org/try", "repo_type": "hg", "access": "scm_level_1"}, + } + context_._projects_timestamp = time.time() if raises: with pytest.raises(ValueError): diff --git a/tests/test_task_process.py b/tests/test_task_process.py index 1f9d9136..fc84eb55 100644 --- a/tests/test_task_process.py +++ b/tests/test_task_process.py @@ -30,15 +30,20 @@ def mock_kill(_, __): @pytest.mark.asyncio -async def test_stop_handle_process_lookup_error(): +async def test_stop_handle_process_lookup_error(monkeypatch): + def mock_kill(_, __): + raise ProcessLookupError() + process = MagicMock() - process.terminate.side_effect = ProcessLookupError task_process = TaskProcess(process) + + monkeypatch.setattr(os, "kill", mock_kill) await task_process.stop() @pytest.mark.asyncio -async def test_set_killed_due_to_worker_shutdown(): +async def test_set_killed_due_to_worker_shutdown(mocker): + mocker.patch.object(os, "kill") task_process = TaskProcess(MagicMock()) assert task_process.stopped_due_to_worker_shutdown is False await task_process.worker_shutdown_stop()