@@ -398,7 +398,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
398398
399399 self .assertIn ("Auth service is unavailable" , str (context .exception ))
400400
401-
402401 @patch .dict (os .environ , {'SUPABASE_URL' : 'http://test.supabase.co' , 'SUPABASE_KEY' : 'test-key' })
403402 async def test_health_check_missing_name_field (self ):
404403 """Test health check with response missing name field (covers line 103)"""
@@ -439,6 +438,46 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
439438
440439 self .assertIn ("Auth service is unavailable" , str (context .exception ))
441440
441+ @patch .dict (os .environ , {'SUPABASE_URL' : 'http://test.supabase.co' , 'SUPABASE_KEY' : 'test-key' })
442+ async def test_health_check_name_not_gotrue (self ):
443+ """Test health check with name field not equal to 'GoTrue' (covers line 103)"""
444+ # Create a proper async context manager mock
445+ class MockResponse :
446+ def __init__ (self ):
447+ self .ok = True
448+
449+ async def json (self ):
450+ return {"name" : "NotGoTrue" } # Name is not "GoTrue"
451+
452+ class MockGet :
453+ def __init__ (self ):
454+ self .response = MockResponse ()
455+
456+ async def __aenter__ (self ):
457+ return self .response
458+
459+ async def __aexit__ (self , exc_type , exc_val , exc_tb ):
460+ return None
461+
462+ class MockSession :
463+ def get (self , * args , ** kwargs ):
464+ return MockGet ()
465+
466+ class MockClientSession :
467+ async def __aenter__ (self ):
468+ return MockSession ()
469+
470+ async def __aexit__ (self , exc_type , exc_val , exc_tb ):
471+ return None
472+
473+ # Patch the ClientSession
474+ with patch ('backend.services.user_management_service.aiohttp.ClientSession' , MockClientSession ):
475+ # Function should raise ConnectionError for wrong name value
476+ with self .assertRaises (ConnectionError ) as context :
477+ await check_auth_service_health ()
478+
479+ self .assertIn ("Auth service is unavailable" , str (context .exception ))
480+
442481 @patch .dict (os .environ , {'SUPABASE_URL' : 'http://test.supabase.co' , 'SUPABASE_KEY' : 'test-key' })
443482 @patch ('backend.services.user_management_service.aiohttp.ClientSession' )
444483 async def test_health_check_connection_error (self , mock_session_cls ):
0 commit comments