Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down Expand Up @@ -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"

Expand Down
6 changes: 6 additions & 0 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 8 additions & 3 deletions tests/test_task_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down