1212from models .responses import ProviderHealthStatus , ReadinessResponse
1313
1414
15- def test_readiness_probe_fails_due_to_unhealthy_providers (mocker ):
15+ async def test_readiness_probe_fails_due_to_unhealthy_providers (mocker ):
1616 """Test the readiness endpoint handler fails when providers are unhealthy."""
1717 # Mock get_providers_health_statuses to return an unhealthy provider
1818 mock_get_providers_health_statuses = mocker .patch (
@@ -29,15 +29,15 @@ def test_readiness_probe_fails_due_to_unhealthy_providers(mocker):
2929 # Mock the Response object
3030 mock_response = Mock ()
3131
32- response = readiness_probe_get_method (mock_response )
32+ response = await readiness_probe_get_method (mock_response )
3333
3434 assert response .ready is False
3535 assert "test_provider" in response .reason
3636 assert "Providers not healthy" in response .reason
3737 assert mock_response .status_code == 503
3838
3939
40- def test_readiness_probe_success_when_all_providers_healthy (mocker ):
40+ async def test_readiness_probe_success_when_all_providers_healthy (mocker ):
4141 """Test the readiness endpoint handler succeeds when all providers are healthy."""
4242 # Mock get_providers_health_statuses to return healthy providers
4343 mock_get_providers_health_statuses = mocker .patch (
@@ -59,7 +59,7 @@ def test_readiness_probe_success_when_all_providers_healthy(mocker):
5959 # Mock the Response object
6060 mock_response = Mock ()
6161
62- response = readiness_probe_get_method (mock_response )
62+ response = await readiness_probe_get_method (mock_response )
6363 assert response is not None
6464 assert isinstance (response , ReadinessResponse )
6565 assert response .ready is True
@@ -98,13 +98,13 @@ def test_provider_health_status_optional_fields(self):
9898class TestGetProvidersHealthStatuses :
9999 """Test cases for the get_providers_health_statuses function."""
100100
101- def test_get_providers_health_statuses (self , mocker ):
101+ async def test_get_providers_health_statuses (self , mocker ):
102102 """Test get_providers_health_statuses with healthy providers."""
103103 # Mock the imports
104- mock_lsc = mocker .patch ("client.LlamaStackClientHolder .get_client" )
104+ mock_lsc = mocker .patch ("client.AsyncLlamaStackClientHolder .get_client" )
105105
106106 # Mock the client and its methods
107- mock_client = mocker .Mock ()
107+ mock_client = mocker .AsyncMock ()
108108 mock_lsc .return_value = mock_client
109109
110110 # Mock providers.list() to return providers with health
@@ -136,7 +136,7 @@ def test_get_providers_health_statuses(self, mocker):
136136 ]
137137
138138 # Mock configuration
139- result = get_providers_health_statuses ()
139+ result = await get_providers_health_statuses ()
140140
141141 assert len (result ) == 3
142142 assert result [0 ].provider_id == "provider1"
@@ -149,15 +149,15 @@ def test_get_providers_health_statuses(self, mocker):
149149 assert result [2 ].status == HealthStatus .ERROR .value
150150 assert result [2 ].message == "Connection failed"
151151
152- def test_get_providers_health_statuses_connection_error (self , mocker ):
152+ async def test_get_providers_health_statuses_connection_error (self , mocker ):
153153 """Test get_providers_health_statuses when connection fails."""
154154 # Mock the imports
155- mock_lsc = mocker .patch ("client.LlamaStackClientHolder .get_client" )
155+ mock_lsc = mocker .patch ("client.AsyncLlamaStackClientHolder .get_client" )
156156
157157 # Mock get_llama_stack_client to raise an exception
158158 mock_lsc .side_effect = Exception ("Connection error" )
159159
160- result = get_providers_health_statuses ()
160+ result = await get_providers_health_statuses ()
161161
162162 assert len (result ) == 1
163163 assert result [0 ].provider_id == "unknown"
0 commit comments