Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fail on repeat #72

Merged
merged 14 commits into from
Jan 13, 2024
Prev Previous commit
Next Next commit
fix elapsed
tsv1 committed Jan 13, 2024
commit a263a2cb64c24f9fe5ea2d6a6ada7b72383529f9
38 changes: 38 additions & 0 deletions tests/core/scenario_result/test_aggregated_result.py
Original file line number Diff line number Diff line change
@@ -115,6 +115,44 @@ def test_from_existing_started_ended(get_scenario_result: Callable[[], ScenarioR
assert aggregated_result.extra_details == scenario_result.extra_details


def test_from_existing_started_at_min():
with given:
scenario_result1 = make_scenario_result().set_started_at(1.0)
scenario_result2 = make_scenario_result().set_started_at(2.0)

with when:
aggregated_result = AggregatedResult.from_existing(scenario_result2,
[scenario_result1, scenario_result2])

with then:
assert aggregated_result.status == scenario_result2.status
assert aggregated_result.started_at == scenario_result1.started_at # min
assert aggregated_result.ended_at == scenario_result2.ended_at
assert aggregated_result.scope == scenario_result2.scope
assert aggregated_result.artifacts == scenario_result2.artifacts
assert aggregated_result.step_results == scenario_result2.step_results
assert aggregated_result.extra_details == scenario_result2.extra_details


def test_from_existing_ended_at_max():
with given:
scenario_result1 = make_scenario_result().set_ended_at(1.0)
scenario_result2 = make_scenario_result().set_ended_at(5.0)

with when:
aggregated_result = AggregatedResult.from_existing(scenario_result1,
[scenario_result1, scenario_result2])

with then:
assert aggregated_result.status == scenario_result1.status
assert aggregated_result.started_at == scenario_result1.started_at
assert aggregated_result.ended_at == scenario_result2.ended_at # max
assert aggregated_result.scope == scenario_result1.scope
assert aggregated_result.artifacts == scenario_result1.artifacts
assert aggregated_result.step_results == scenario_result1.step_results
assert aggregated_result.extra_details == scenario_result1.extra_details


def test_from_existing_artifacts():
with given:
scenario_result = make_scenario_result()
12 changes: 7 additions & 5 deletions vedro/core/scenario_result/_aggregated_result.py
Original file line number Diff line number Diff line change
@@ -31,11 +31,6 @@ def from_existing(main_scenario_result: ScenarioResult,
elif main_scenario_result.is_skipped():
result.mark_skipped()

if main_scenario_result.started_at is not None:
result.set_started_at(main_scenario_result.started_at)
if main_scenario_result.ended_at is not None:
result.set_ended_at(main_scenario_result.ended_at)

result.set_scope(main_scenario_result.scope)

for step_result in main_scenario_result.step_results:
@@ -49,6 +44,13 @@ def from_existing(main_scenario_result: ScenarioResult,

assert len(scenario_results) > 0
for scenario_result in scenario_results:
if scenario_result.started_at is not None:
if (result.started_at is None) or (scenario_result.started_at < result.started_at):
result.set_started_at(scenario_result.started_at)
if scenario_result.ended_at is not None:
if (result.ended_at is None) or (scenario_result.ended_at > result.ended_at):
result.set_ended_at(scenario_result.ended_at)

result.add_scenario_result(scenario_result)

return result