77"""
88
99import pytest
10+
1011from renku_data_services .metrics .core import StagingMetricsService
1112from renku_data_services .notebooks .core_sessions import _make_patch_spec_list
1213
1314
1415@pytest .mark .asyncio
1516async def test_session_metrics_metadata_structure ():
1617 """Test that session metrics store metadata with correct structure."""
18+
1719 # Create mock metrics repo
1820 async def mock_store_event (* args , ** kwargs ):
1921 pass
@@ -24,10 +26,14 @@ async def mock_store_event(*args, **kwargs):
2426 metrics = StagingMetricsService (enabled = True , metrics_repo = mock_metrics_repo )
2527
2628 # Create mock user with required attributes
27- mock_user = type ("APIUser" , (), {
28- "id" : "test-user-123" ,
29- "is_authenticated" : True ,
30- })()
29+ mock_user = type (
30+ "APIUser" ,
31+ (),
32+ {
33+ "id" : "test-user-123" ,
34+ "is_authenticated" : True ,
35+ },
36+ )()
3137
3238 # Test session_started metadata with all resource fields
3339 await metrics .session_started (
@@ -122,11 +128,12 @@ class MyResource:
122128@pytest .mark .asyncio
123129async def test_session_metrics_metadata_fields_match_implementation ():
124130 """Verify that test metadata matches what's actually sent in the implementation.
125-
131+
126132 This test validates the exact metadata fields that are sent from:
127133 - k8s watcher (session_started, session_resumed, session_hibernated, session_stopped)
128134 - notebooks.core_sessions (user_requested_session_resume)
129135 """
136+
130137 # Create mock metrics repo
131138 async def mock_store_event (* args , ** kwargs ):
132139 pass
@@ -135,10 +142,14 @@ async def mock_store_event(*args, **kwargs):
135142 metrics = StagingMetricsService (enabled = True , metrics_repo = mock_metrics_repo )
136143
137144 # Create mock user
138- mock_user = type ("APIUser" , (), {
139- "id" : "test-user-123" ,
140- "is_authenticated" : True ,
141- })()
145+ mock_user = type (
146+ "APIUser" ,
147+ (),
148+ {
149+ "id" : "test-user-123" ,
150+ "is_authenticated" : True ,
151+ },
152+ )()
142153
143154 # Test ALL the metadata fields that are actually sent in the implementation
144155 # From: components/renku_data_services/k8s/watcher/core.py:208-219 (session_started/resumed)
0 commit comments