Skip to content

Commit

Permalink
min cot version tests
Browse files Browse the repository at this point in the history
  • Loading branch information
escapewindow committed Jan 10, 2018
1 parent e23db08 commit 3d2a844
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions scriptworker/test/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,9 +1092,17 @@ def test_verify_parent_task_definition(chain, decision_link, action_link, cron_l

# verify_parent_task {{{1
@pytest.mark.asyncio
@pytest.mark.parametrize("defn_fn", (noop_async, die_async))
@pytest.mark.parametrize("defn_fn,min_cot_version,raises", ((
noop_async, 1, False
), (
die_async, 1, False
), (
die_async, 2, True
)))
async def test_verify_parent_task(chain, action_link, cron_link,
decision_link, build_link, mocker, defn_fn):
decision_link, build_link, mocker, defn_fn,
min_cot_version, raises):
chain.context.config['min_cot_version'] = min_cot_version
for parent_link in (action_link, cron_link, decision_link):
build_link.decision_task_id = parent_link.decision_task_id
build_link.parent_task_id = parent_link.task_id
Expand All @@ -1121,11 +1129,17 @@ def task_graph(*args, **kwargs):
mocker.patch.object(cotverify, 'load_json_or_yaml', new=task_graph)
mocker.patch.object(cotverify, 'verify_decision_command', new=noop_sync)
mocker.patch.object(cotverify, 'verify_parent_task_definition', new=defn_fn)
await cotverify.verify_parent_task(chain, parent_link)
# Deal with chain == link scenario
chain.task = parent_link.task
chain.links = []
await cotverify.verify_parent_task(chain, chain)
if raises:
with pytest.raises(CoTError):
await cotverify.verify_parent_task(chain, parent_link)
else:
await cotverify.verify_parent_task(chain, parent_link)
# Deal with chain == link scenario
orig_chain_task = chain.task
chain.task = parent_link.task
chain.links = []
await cotverify.verify_parent_task(chain, chain)
chain.task = orig_chain_task


@pytest.mark.asyncio
Expand Down

0 comments on commit 3d2a844

Please sign in to comment.