66
77import pytest
88
9+ from runloop_api_client .sdk .async_snapshot import AsyncSnapshot
10+ from runloop_api_client .sdk .async_blueprint import AsyncBlueprint
911from runloop_api_client .sdk .async_scenario_builder import AsyncScenarioBuilder
1012
1113
@@ -20,6 +22,16 @@ def mock_async_client(self) -> MagicMock:
2022 client .scenarios .create = AsyncMock ()
2123 return client
2224
25+ @pytest .fixture
26+ def mock_blueprint (self , mock_async_client : MagicMock ) -> AsyncBlueprint :
27+ """Create a mock AsyncBlueprint object."""
28+ return AsyncBlueprint (mock_async_client , "bp-123" )
29+
30+ @pytest .fixture
31+ def mock_snapshot (self , mock_async_client : MagicMock ) -> AsyncSnapshot :
32+ """Create a mock AsyncSnapshot object."""
33+ return AsyncSnapshot (mock_async_client , "snap-123" )
34+
2335 @pytest .fixture
2436 def builder (self , mock_async_client : MagicMock ) -> AsyncScenarioBuilder :
2537 """Create an AsyncScenarioBuilder instance with mock client."""
@@ -37,21 +49,21 @@ def test_repr(self, builder: AsyncScenarioBuilder) -> None:
3749 """Test builder __repr__."""
3850 assert repr (builder ) == "<AsyncScenarioBuilder name='test-scenario'>"
3951
40- def test_from_blueprint_id_returns_self (self , builder : AsyncScenarioBuilder ) -> None :
41- """Test from_blueprint_id returns self for chaining."""
42- result = builder .from_blueprint_id ( "bp-123" )
52+ def test_from_blueprint_returns_self (self , builder : AsyncScenarioBuilder , mock_blueprint : AsyncBlueprint ) -> None :
53+ """Test from_blueprint returns self for chaining."""
54+ result = builder .from_blueprint ( mock_blueprint )
4355
4456 assert result is builder
45- assert builder ._blueprint_id == "bp-123"
46- assert builder ._snapshot_id is None
57+ assert builder ._blueprint is mock_blueprint
58+ assert builder ._snapshot is None
4759
48- def test_from_snapshot_id_returns_self (self , builder : AsyncScenarioBuilder ) -> None :
49- """Test from_snapshot_id returns self for chaining."""
50- result = builder .from_snapshot_id ( "snap-123" )
60+ def test_from_snapshot_returns_self (self , builder : AsyncScenarioBuilder , mock_snapshot : AsyncSnapshot ) -> None :
61+ """Test from_snapshot returns self for chaining."""
62+ result = builder .from_snapshot ( mock_snapshot )
5163
5264 assert result is builder
53- assert builder ._snapshot_id == "snap-123"
54- assert builder ._blueprint_id is None
65+ assert builder ._snapshot is mock_snapshot
66+ assert builder ._blueprint is None
5567
5668 def test_with_working_directory_returns_self (self , builder : AsyncScenarioBuilder ) -> None :
5769 """Test with_working_directory returns self for chaining."""
@@ -125,11 +137,11 @@ def test_build_params_minimal(self, builder: AsyncScenarioBuilder) -> None:
125137 assert params ["input_context" ]["problem_statement" ] == "Fix the bug"
126138 assert len (params ["scoring_contract" ]["scoring_function_parameters" ]) == 1
127139
128- def test_build_params_with_environment (self , builder : AsyncScenarioBuilder ) -> None :
140+ def test_build_params_with_environment (self , builder : AsyncScenarioBuilder , mock_blueprint : AsyncBlueprint ) -> None :
129141 """Test _build_params includes environment parameters."""
130142 builder .with_problem_statement ("Fix the bug" )
131143 builder .add_test_scorer ("tests" , test_command = "pytest" )
132- builder .from_blueprint_id ( "bp-123" )
144+ builder .from_blueprint ( mock_blueprint )
133145 builder .with_working_directory ("/app" )
134146
135147 params = builder ._build_params ()
@@ -156,10 +168,10 @@ async def test_push_calls_api_and_returns_scenario(
156168
157169 assert scenario .id == "scn-new-123"
158170
159- def test_fluent_chaining (self , builder : AsyncScenarioBuilder ) -> None :
171+ def test_fluent_chaining (self , builder : AsyncScenarioBuilder , mock_blueprint : AsyncBlueprint ) -> None :
160172 """Test that all builder methods can be chained fluently."""
161173 result = (
162- builder .from_blueprint_id ( "bp-123" )
174+ builder .from_blueprint ( mock_blueprint )
163175 .with_working_directory ("/app" )
164176 .with_problem_statement ("Fix the bug" )
165177 .with_additional_context ({"hint" : "check main.py" })
@@ -172,7 +184,7 @@ def test_fluent_chaining(self, builder: AsyncScenarioBuilder) -> None:
172184 )
173185
174186 assert result is builder
175- assert builder ._blueprint_id == "bp-123"
187+ assert builder ._blueprint is mock_blueprint
176188 assert builder ._working_directory == "/app"
177189 assert builder ._problem_statement == "Fix the bug"
178190 assert len (builder ._scorers ) == 1
0 commit comments