QTZPOC-20
QTZPOC-20: Refactor test inputs into named variables for improved readability and debugging.
This commit is contained in:
@@ -322,9 +322,10 @@ async def test_a_failing_step_is_recorded_as_that_step_and_stops_the_import(
|
||||
):
|
||||
recorder = Recorder(failures={failing: RuntimeError('dependency unavailable')})
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError, match='dependency unavailable'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -353,9 +354,10 @@ async def test_nothing_is_provisioned_before_the_gates_pass(import_workflow: Imp
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportGateRejectedError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -377,9 +379,10 @@ async def test_a_gate_rejection_is_recorded_with_the_gate_that_rejected_it(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportGateRejectedError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -398,9 +401,10 @@ async def test_an_ambiguous_decryption_failure_keeps_its_step(import_workflow: I
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportGateRejectedError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -420,9 +424,10 @@ async def test_an_unknown_field_is_rejected_rather_than_ignored(
|
||||
"""A caller that believes it recorded a project link must be told it did not."""
|
||||
recorder = Recorder()
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input(**{field: 'whatever'})
|
||||
try:
|
||||
with raises(ImportInputError, match='does not accept'):
|
||||
await import_workflow.run(valid_input(**{field: 'whatever'}))
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -445,9 +450,10 @@ async def test_a_missing_or_malformed_digest_fails_before_anything_is_downloaded
|
||||
):
|
||||
recorder = Recorder()
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input(expected_digest=digest)
|
||||
try:
|
||||
with raises(ImportInputError):
|
||||
await import_workflow.run(valid_input(expected_digest=digest))
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -490,9 +496,10 @@ async def test_a_record_naming_another_object_is_a_received_failure(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportInputError, match='different object'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -513,9 +520,10 @@ async def test_a_record_naming_another_digest_is_a_received_failure(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportInputError, match='different digest'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -528,9 +536,10 @@ async def test_an_unusable_record_id_fails_before_any_activity(import_workflow:
|
||||
"""There is no record to claim and none to write: the run ends FAILED and nothing is touched."""
|
||||
recorder = Recorder()
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input(import_run_id=value)
|
||||
try:
|
||||
with raises(ImportInputError, match='positive integer'):
|
||||
await import_workflow.run(valid_input(import_run_id=value))
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -547,9 +556,10 @@ async def test_a_claim_that_matches_nothing_writes_nothing_at_all(import_workflo
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportLogRowNotClaimableError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -651,9 +661,10 @@ async def test_a_terminal_write_failure_does_not_mask_a_real_failure(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError, match='registry refused'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -709,9 +720,10 @@ async def test_the_failure_that_ends_an_import_is_reported_through_the_channel(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError, match='Activity task failed'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -732,9 +744,10 @@ async def test_the_report_comes_before_the_cleanup_and_the_terminal_write(
|
||||
failures={Activities.upload_import_artifacts: activity_failure('bucket gone', 'S3Error')}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -761,9 +774,10 @@ async def test_the_gate_that_rejected_the_bundle_travels_into_the_report(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportGateRejectedError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -783,9 +797,10 @@ async def test_a_claim_that_matches_nothing_is_not_reported_twice(import_workflo
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(ImportLogRowNotClaimableError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -803,9 +818,10 @@ async def test_a_report_that_cannot_be_made_does_not_mask_the_failure(
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError, match='Activity task failed'):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
@@ -830,9 +846,10 @@ async def test_the_report_gives_up_inside_the_short_bound(import_workflow: Impor
|
||||
}
|
||||
)
|
||||
patcher, _ = run_with(recorder)
|
||||
payload = valid_input()
|
||||
try:
|
||||
with raises(RuntimeError):
|
||||
await import_workflow.run(valid_input())
|
||||
await import_workflow.run(payload)
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user