Skip to content

Commit 46b93e3

Browse files
committed
consolidate from_blueprint and from_snapshot unit tests
1 parent d3a53ce commit 46b93e3

2 files changed

Lines changed: 18 additions & 28 deletions

File tree

tests/sdk/test_async_scenario_builder.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,27 @@ def test_repr(self, builder: AsyncScenarioBuilder) -> None:
4949
"""Test builder __repr__."""
5050
assert repr(builder) == "<AsyncScenarioBuilder name='test-scenario'>"
5151

52-
def test_from_blueprint_returns_self(self, builder: AsyncScenarioBuilder, mock_blueprint: AsyncBlueprint) -> None:
53-
"""Test from_blueprint returns self for chaining."""
52+
def test_from_blueprint_and_snapshot(
53+
self, builder: AsyncScenarioBuilder, mock_blueprint: AsyncBlueprint, mock_snapshot: AsyncSnapshot
54+
) -> None:
55+
"""Test blueprint/snapshot setting returns self and are mutually exclusive."""
56+
# from_blueprint returns self and sets blueprint
5457
result = builder.from_blueprint(mock_blueprint)
55-
5658
assert result is builder
5759
assert builder._blueprint is mock_blueprint
5860
assert builder._snapshot is None
5961

60-
def test_from_snapshot_returns_self(self, builder: AsyncScenarioBuilder, mock_snapshot: AsyncSnapshot) -> None:
61-
"""Test from_snapshot returns self for chaining."""
62+
# from_snapshot returns self, sets snapshot, and clears blueprint
6263
result = builder.from_snapshot(mock_snapshot)
63-
6464
assert result is builder
6565
assert builder._snapshot is mock_snapshot
6666
assert builder._blueprint is None
6767

68+
# from_blueprint clears snapshot
69+
builder.from_blueprint(mock_blueprint)
70+
assert builder._blueprint is mock_blueprint
71+
assert builder._snapshot is None
72+
6873
def test_with_working_directory_returns_self(self, builder: AsyncScenarioBuilder) -> None:
6974
"""Test with_working_directory returns self for chaining."""
7075
result = builder.with_working_directory("/app")

tests/sdk/test_scenario_builder.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,27 @@ def test_repr(self, builder: ScenarioBuilder) -> None:
4848
"""Test builder __repr__."""
4949
assert repr(builder) == "<ScenarioBuilder name='test-scenario'>"
5050

51-
def test_from_blueprint_returns_self(self, builder: ScenarioBuilder, mock_blueprint: Blueprint) -> None:
52-
"""Test from_blueprint returns self for chaining."""
51+
def test_from_blueprint_and_snapshot(
52+
self, builder: ScenarioBuilder, mock_blueprint: Blueprint, mock_snapshot: Snapshot
53+
) -> None:
54+
"""Test blueprint/snapshot setting returns self and are mutually exclusive."""
55+
# from_blueprint returns self and sets blueprint
5356
result = builder.from_blueprint(mock_blueprint)
54-
5557
assert result is builder
5658
assert builder._blueprint is mock_blueprint
5759
assert builder._snapshot is None
5860

59-
def test_from_snapshot_returns_self(self, builder: ScenarioBuilder, mock_snapshot: Snapshot) -> None:
60-
"""Test from_snapshot returns self for chaining."""
61+
# from_snapshot returns self, sets snapshot, and clears blueprint
6162
result = builder.from_snapshot(mock_snapshot)
62-
6363
assert result is builder
6464
assert builder._snapshot is mock_snapshot
6565
assert builder._blueprint is None
6666

67-
def test_from_blueprint_clears_snapshot(
68-
self, builder: ScenarioBuilder, mock_blueprint: Blueprint, mock_snapshot: Snapshot
69-
) -> None:
70-
"""Test that setting blueprint clears snapshot."""
71-
builder.from_snapshot(mock_snapshot)
67+
# from_blueprint clears snapshot
7268
builder.from_blueprint(mock_blueprint)
73-
7469
assert builder._blueprint is mock_blueprint
7570
assert builder._snapshot is None
7671

77-
def test_from_snapshot_clears_blueprint(
78-
self, builder: ScenarioBuilder, mock_blueprint: Blueprint, mock_snapshot: Snapshot
79-
) -> None:
80-
"""Test that setting snapshot clears blueprint."""
81-
builder.from_blueprint(mock_blueprint)
82-
builder.from_snapshot(mock_snapshot)
83-
84-
assert builder._snapshot is mock_snapshot
85-
assert builder._blueprint is None
86-
8772
def test_with_working_directory_returns_self(self, builder: ScenarioBuilder) -> None:
8873
"""Test with_working_directory returns self for chaining."""
8974
result = builder.with_working_directory("/app")

0 commit comments

Comments
 (0)