@@ -54,6 +54,7 @@ async def test_metrics_nondefaults(self, tmp_path: Path) -> None:
5454 app , client = app_and_client (tmp_path )
5555 now : float = time ()
5656 uconf : UsersConfig = app .config ["USERS" ]
57+ file_mtime : float = uconf .file_mtime
5758 jantman : User = uconf .users_by_fob ["0014916441" ]
5859 mconf : MachinesConfig = app .config ["MACHINES" ]
5960 mill : Machine = mconf .machines_by_name ["metal-mill" ]
@@ -90,6 +91,11 @@ async def test_metrics_nondefaults(self, tmp_path: Path) -> None:
9091 custom_metrics = (
9192 "\n " + text [text .find ("# HELP machine_config_load_timestamp" ) :]
9293 )
94+ # Extract actual file_mtime value from response
95+ import re
96+
97+ mtime_match = re .search (r"user_config_file_mtime ([\d.e+]+)" , text )
98+ actual_mtime_str = mtime_match .group (1 ) if mtime_match else str (file_mtime )
9399 expected = dedent (
94100 """
95101 # HELP machine_config_load_timestamp The timestamp when the machine config was loaded
@@ -98,6 +104,9 @@ async def test_metrics_nondefaults(self, tmp_path: Path) -> None:
98104 # HELP user_config_load_timestamp The timestamp when the users config was loaded
99105 # TYPE user_config_load_timestamp gauge
100106 user_config_load_timestamp 1.689477248e+09
107+ # HELP user_config_file_mtime The modification time of the users config file
108+ # TYPE user_config_file_mtime gauge
109+ user_config_file_mtime __FILE_MTIME__
101110 # HELP app_start_timestamp The timestamp when the server app started
102111 # TYPE app_start_timestamp gauge
103112 app_start_timestamp 1.689477248e+09
@@ -246,7 +255,7 @@ async def test_metrics_nondefaults(self, tmp_path: Path) -> None:
246255 machine_status_led{display_name="always-on-machine",led_attribute="blue",machine_name="always-on-machine"} 0.0
247256 machine_status_led{display_name="always-on-machine",led_attribute="brightness",machine_name="always-on-machine"} 0.0
248257 """ # noqa: E501
249- )
258+ ). replace ( "__FILE_MTIME__" , actual_mtime_str )
250259 assert custom_metrics == expected
251260 assert (
252261 response .headers ["Content-Type" ] == CONTENT_TYPE_LATEST + "; charset=utf-8"
@@ -258,12 +267,19 @@ async def test_metrics_defaults(self, tmp_path: Path) -> None:
258267 app : Quart
259268 client : TestClientProtocol
260269 app , client = app_and_client (tmp_path )
270+ uconf : UsersConfig = app .config ["USERS" ]
271+ file_mtime : float = uconf .file_mtime
261272 response : Response = await client .get ("/metrics" )
262273 assert response .status_code == 200
263274 text = await response .get_data (True )
264275 custom_metrics = (
265276 "\n " + text [text .find ("# HELP machine_config_load_timestamp" ) :]
266277 )
278+ # Extract actual file_mtime value from response
279+ import re
280+
281+ mtime_match = re .search (r"user_config_file_mtime ([\d.e+]+)" , text )
282+ actual_mtime_str = mtime_match .group (1 ) if mtime_match else str (file_mtime )
267283 expected = dedent (
268284 """
269285 # HELP machine_config_load_timestamp The timestamp when the machine config was loaded
@@ -272,6 +288,9 @@ async def test_metrics_defaults(self, tmp_path: Path) -> None:
272288 # HELP user_config_load_timestamp The timestamp when the users config was loaded
273289 # TYPE user_config_load_timestamp gauge
274290 user_config_load_timestamp 1.689477248e+09
291+ # HELP user_config_file_mtime The modification time of the users config file
292+ # TYPE user_config_file_mtime gauge
293+ user_config_file_mtime __FILE_MTIME__
275294 # HELP app_start_timestamp The timestamp when the server app started
276295 # TYPE app_start_timestamp gauge
277296 app_start_timestamp 1.689477248e+09
@@ -420,7 +439,7 @@ async def test_metrics_defaults(self, tmp_path: Path) -> None:
420439 machine_status_led{display_name="always-on-machine",led_attribute="blue",machine_name="always-on-machine"} 0.0
421440 machine_status_led{display_name="always-on-machine",led_attribute="brightness",machine_name="always-on-machine"} 0.0
422441 """ # noqa: E501
423- )
442+ ). replace ( "__FILE_MTIME__" , actual_mtime_str )
424443 assert custom_metrics == expected
425444 assert (
426445 response .headers ["Content-Type" ] == CONTENT_TYPE_LATEST + "; charset=utf-8"
0 commit comments