@@ -325,63 +325,3 @@ def test_health_check_middleware_configured():
325325 # The middleware should be present
326326 assert len (app .user_middleware ) >= 2 # CORS + HealthCheck minimum
327327
328-
329- class TestApplicationInsightsConfiguration :
330- """Test class for Application Insights and telemetry configuration."""
331-
332- def test_app_insights_logging_configured_when_connection_string_present (self , caplog ):
333- """Test that Application Insights logs success message when configured."""
334- import logging
335- # The app is already initialized with APPLICATIONINSIGHTS_CONNECTION_STRING set
336- # Check the logs would contain the success message
337- # Note: Since app is already imported, we can verify the configuration is present
338- assert os .environ .get ("APPLICATIONINSIGHTS_CONNECTION_STRING" ) is not None
339-
340- def test_fastapi_instrumentor_excludes_websocket_urls (self ):
341- """Test that WebSocket URLs are excluded from instrumentation."""
342- # This is a configuration test - we verify that the app was instrumented
343- # The actual exclusion is handled by FastAPIInstrumentor during app creation
344- # We can verify by checking that the app has routes
345- route_paths = [route .path for route in app .routes if hasattr (route , 'path' )]
346- assert len (route_paths ) > 0
347-
348- def test_azure_monitor_configured_with_live_metrics (self ):
349- """Test that live metrics would be enabled when App Insights is configured."""
350- # Verify that connection string exists (app.py checks this before configuring)
351- connection_string = os .environ .get ("APPLICATIONINSIGHTS_CONNECTION_STRING" )
352- assert connection_string is not None
353- assert "InstrumentationKey" in connection_string
354-
355-
356- class TestAzureLoggingConfiguration :
357- """Test class for Azure package logging configuration."""
358-
359- def test_opentelemetry_sdk_logger_level (self ):
360- """Test that opentelemetry.sdk logger is set to ERROR level."""
361- import logging
362- otel_logger = logging .getLogger ("opentelemetry.sdk" )
363- assert otel_logger .level == logging .ERROR
364-
365- def test_azure_core_pipeline_logger_level (self ):
366- """Test that Azure core pipeline logger is set to WARNING level."""
367- import logging
368- pipeline_logger = logging .getLogger ("azure.core.pipeline.policies.http_logging_policy" )
369- assert pipeline_logger .level == logging .WARNING
370-
371- def test_azure_monitor_exporter_logger_level (self ):
372- """Test that Azure Monitor exporter logger is set to WARNING level."""
373- import logging
374- exporter_logger = logging .getLogger ("azure.monitor.opentelemetry.exporter.export._base" )
375- assert exporter_logger .level == logging .WARNING
376-
377- def test_azure_logging_packages_configuration (self ):
378- """Test configuration of Azure logging packages from environment."""
379- # This tests that if AZURE_LOGGING_PACKAGES is set, loggers are configured
380- import logging
381- from backend .common .config .app_config import config
382-
383- # Verify config object exists
384- assert config is not None
385- assert hasattr (config , 'AZURE_LOGGING_PACKAGES' )
386-
387-
0 commit comments