From 7148e0e82eda10b9b6799d59b86941efa3c1ec59 Mon Sep 17 00:00:00 2001 From: Hangfei Lin Date: Wed, 10 Sep 2025 10:47:48 -0700 Subject: [PATCH] test: Add tests for Runner initialization constraints These tests verify that `ValueError` is raised when `Runner` is initialized without providing either an `app` instance or both `app_name` and `agent`. PiperOrigin-RevId: 805427256 --- tests/unittests/test_runners.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unittests/test_runners.py b/tests/unittests/test_runners.py index 46902481..01b86ae9 100644 --- a/tests/unittests/test_runners.py +++ b/tests/unittests/test_runners.py @@ -442,6 +442,30 @@ class TestRunnerWithPlugins: artifact_service=self.artifact_service, ) + def test_runner_init_raises_error_without_app_and_app_name(self): + """Test ValueError is raised when app is not provided and app_name is missing.""" + with pytest.raises( + ValueError, + match="Either app or both app_name and agent must be provided.", + ): + Runner( + agent=self.root_agent, + session_service=self.session_service, + artifact_service=self.artifact_service, + ) + + def test_runner_init_raises_error_without_app_and_agent(self): + """Test ValueError is raised when app is not provided and agent is missing.""" + with pytest.raises( + ValueError, + match="Either app or both app_name and agent must be provided.", + ): + Runner( + app_name="test_app", + session_service=self.session_service, + artifact_service=self.artifact_service, + ) + if __name__ == "__main__": pytest.main([__file__])