@@ -106,23 +106,23 @@ def _has_metric_approx(output, prefix):
106106class TestDownstreamChannelMetrics :
107107 def test_ds_power_dbmv (self ):
108108 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
109- assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="1"} 3.0' )
109+ assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="1",frequency="474" } 3.0' )
110110
111111 def test_ds_snr_db (self ):
112112 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
113- assert _has_metric (out , 'docsight_downstream_snr_db{channel_id="1"} 35.0' )
113+ assert _has_metric (out , 'docsight_downstream_snr_db{channel_id="1",frequency="474" } 35.0' )
114114
115115 def test_ds_corrected_errors_total (self ):
116116 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
117- assert _has_metric (out , 'docsight_downstream_corrected_errors_total{channel_id="1"} 100' )
117+ assert _has_metric (out , 'docsight_downstream_corrected_errors_total{channel_id="1",frequency="474" } 100' )
118118
119119 def test_ds_uncorrected_errors_total (self ):
120120 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
121- assert _has_metric (out , 'docsight_downstream_uncorrected_errors_total{channel_id="1"} 5' )
121+ assert _has_metric (out , 'docsight_downstream_uncorrected_errors_total{channel_id="1",frequency="474" } 5' )
122122
123123 def test_ds_modulation_256qam (self ):
124124 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
125- assert _has_metric (out , 'docsight_downstream_modulation{channel_id="1"} 256' )
125+ assert _has_metric (out , 'docsight_downstream_modulation{channel_id="1",frequency="474" } 256' )
126126
127127 def test_ds_snr_none_omits_line (self ):
128128 analysis = {
@@ -146,7 +146,7 @@ def test_ds_snr_none_omits_line(self):
146146 "us_channels" : [],
147147 }
148148 out = format_metrics (analysis , None , None , 0.0 )
149- assert not _has_metric_approx (out , 'docsight_downstream_snr_db{channel_id="5"}' )
149+ assert not _has_metric_approx (out , 'docsight_downstream_snr_db{channel_id="5",frequency="474" }' )
150150
151151 def test_ds_modulation_ofdm_omits_line (self ):
152152 """OFDM is not parseable as QAM order, so modulation line must be omitted."""
@@ -171,16 +171,16 @@ def test_ds_modulation_ofdm_omits_line(self):
171171 "us_channels" : [],
172172 }
173173 out = format_metrics (analysis , None , None , 0.0 )
174- assert not _has_metric_approx (out , 'docsight_downstream_modulation{channel_id="7"}' )
174+ assert not _has_metric_approx (out , 'docsight_downstream_modulation{channel_id="7",frequency="474" }' )
175175
176176 def test_multiple_ds_channels_separate_lines (self ):
177177 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
178- assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="1"} 3.0' )
179- assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="2"} -1.5' )
178+ assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="1",frequency="474" } 3.0' )
179+ assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="2",frequency="482" } -1.5' )
180180
181181 def test_ds_power_negative_value (self ):
182182 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
183- assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="2"} -1.5' )
183+ assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="2",frequency="482" } -1.5' )
184184
185185 def test_ds_has_help_comment (self ):
186186 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
@@ -200,11 +200,11 @@ def test_ds_has_type_comment(self):
200200class TestUpstreamChannelMetrics :
201201 def test_us_power_dbmv (self ):
202202 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
203- assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="1"} 42.0' )
203+ assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="1",frequency="30" } 42.0' )
204204
205205 def test_us_modulation_64qam (self ):
206206 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
207- assert _has_metric (out , 'docsight_upstream_modulation{channel_id="1"} 64' )
207+ assert _has_metric (out , 'docsight_upstream_modulation{channel_id="1",frequency="30" } 64' )
208208
209209 def test_us_power_none_omits_line (self ):
210210 analysis = {
@@ -225,7 +225,7 @@ def test_us_power_none_omits_line(self):
225225 }],
226226 }
227227 out = format_metrics (analysis , None , None , 0.0 )
228- assert not _has_metric_approx (out , 'docsight_upstream_power_dbmv{channel_id="3"}' )
228+ assert not _has_metric_approx (out , 'docsight_upstream_power_dbmv{channel_id="3",frequency="30" }' )
229229
230230 def test_multiple_us_channels_separate_lines (self ):
231231 analysis = {
@@ -257,8 +257,41 @@ def test_multiple_us_channels_separate_lines(self):
257257 ],
258258 }
259259 out = format_metrics (analysis , None , None , 0.0 )
260- assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="1"} 42.0' )
261- assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="2"} 45.0' )
260+ assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="1",frequency="30"} 42.0' )
261+ assert _has_metric (out , 'docsight_upstream_power_dbmv{channel_id="2",frequency="38"} 45.0' )
262+
263+ def test_frequency_label_normalizes_mhz_values (self ):
264+ analysis = {
265+ "summary" : {
266+ "ds_total" : 1 , "us_total" : 1 ,
267+ "health" : "good" , "health_issues" : [],
268+ "ds_correctable_errors" : 0 , "ds_uncorrectable_errors" : 0 ,
269+ },
270+ "ds_channels" : [{
271+ "channel_id" : 9 ,
272+ "frequency" : "114.0 MHz" ,
273+ "power" : 2.5 ,
274+ "modulation" : "256QAM" ,
275+ "snr" : 36.0 ,
276+ "correctable_errors" : 0 ,
277+ "uncorrectable_errors" : 0 ,
278+ "docsis_version" : "3.0" ,
279+ "health" : "good" ,
280+ "health_detail" : "" ,
281+ }],
282+ "us_channels" : [{
283+ "channel_id" : 2 ,
284+ "frequency" : "44 MHz" ,
285+ "power" : 43.0 ,
286+ "modulation" : "64QAM" ,
287+ "docsis_version" : "3.0" ,
288+ "health" : "good" ,
289+ "health_detail" : "" ,
290+ }],
291+ }
292+ out = format_metrics (analysis , None , None , 0.0 )
293+ assert _has_metric (out , 'docsight_downstream_power_dbmv{channel_id="9",frequency="114.0"} 2.5' )
294+ assert _has_metric (out , 'docsight_upstream_modulation{channel_id="2",frequency="44"} 64' )
262295
263296 def test_us_has_help_comment (self ):
264297 out = format_metrics (ANALYSIS_FULL , None , None , 0.0 )
0 commit comments