Skip to content

Commit 1f3041c

Browse files
Евгений БлиновЕвгений Блинов
authored andcommitted
Add test for Scenario.__radd__ and validate JSON deserialization
1 parent d42dcc6 commit 1f3041c

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

tests/units/test_benchmark_result.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,8 @@ def test_from_json_missing_is_primary_raises(self) -> None:
404404
payload = json.dumps({'durations': [0.1, 0.2]})
405405
with pytest.raises(ValueError, match='required fields'):
406406
BenchmarkResult.from_json(payload)
407+
408+
def test_from_json_not_dict_raises(self) -> None:
409+
payload = json.dumps([1, 2, 3])
410+
with pytest.raises(ValueError, match='JSON must be an object'):
411+
BenchmarkResult.from_json(payload)

tests/units/test_scenario.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ def test_add_unknown_type_returns_not_implemented(self) -> None:
271271
result = s.__add__(42) # type: ignore[arg-type]
272272
assert result is NotImplemented
273273

274+
def test_radd_scenario_scenario(self) -> None:
275+
s1 = Scenario(lambda: None, name='s1')
276+
s2 = Scenario(lambda: None, name='s2')
277+
# s2.__radd__(s1) = ScenarioGroup(s1, s2)
278+
group = s2.__radd__(s1)
279+
assert isinstance(group, ScenarioGroup)
280+
results = group.run()
281+
assert results[0].scenario is s1
282+
assert results[1].scenario is s2
283+
274284
def test_radd_group_scenario(self) -> None:
275285
s1 = Scenario(lambda: None, name='s1')
276286
s2 = Scenario(lambda: None, name='s2')

0 commit comments

Comments
 (0)