@@ -143,7 +143,10 @@ def test_inventory_printer_supply(
143143 ["Magenta Ink Cartridge" , "15" , "-2" , "5" , "3" , "1" ],
144144 ],
145145 ],
146- [Result (state = State .OK , summary = "Level: 5" ), Metric ("pages" , 5 )],
146+ [
147+ Result (state = State .OK , summary = "Supply: 5 tenths of milliliters" ),
148+ Metric ("supply_toner_magenta" , 5 ),
149+ ],
147150 ),
148151 (
149152 "Magenta Ink Cartridge" ,
@@ -156,10 +159,11 @@ def test_inventory_printer_supply(
156159 ],
157160 [
158161 Result (
159- state = State .CRIT , summary = "Remaining: 5.00% (warn/crit below 20.00%/10.00%)"
162+ state = State .CRIT ,
163+ summary = "Supply level remaining: 5.00% (warn/crit below 20.00%/10.00%)" ,
160164 ),
165+ Metric ("supply_toner_magenta" , 5.0 ),
161166 Result (state = State .OK , summary = "Supply: 5 of max. 100 tenths of milliliters" ),
162- Metric ("pages" , 5 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
163167 ],
164168 ),
165169 (
@@ -173,10 +177,11 @@ def test_inventory_printer_supply(
173177 ],
174178 [
175179 Result (
176- state = State .WARN , summary = "Remaining: 15.00% (warn/crit below 20.00%/10.00%)"
180+ state = State .WARN ,
181+ summary = "Supply level remaining: 15.00% (warn/crit below 20.00%/10.00%)" ,
177182 ),
183+ Metric ("supply_toner_magenta" , 15.0 ),
178184 Result (state = State .OK , summary = "Supply: 15 of max. 100 tenths of milliliters" ),
179- Metric ("pages" , 15 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
180185 ],
181186 ),
182187 (
@@ -189,9 +194,9 @@ def test_inventory_printer_supply(
189194 ],
190195 ],
191196 [
192- Result (state = State .OK , summary = "Remaining: 25.00%" ),
197+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
198+ Metric ("supply_toner_magenta" , 25.0 ),
193199 Result (state = State .OK , summary = "Supply: 25 of max. 100 tenths of milliliters" ),
194- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
195200 ],
196201 ),
197202 (
@@ -204,9 +209,9 @@ def test_inventory_printer_supply(
204209 ],
205210 ],
206211 [
207- Result (state = State .OK , summary = "Remaining: 25.00%" ),
212+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
213+ Metric ("supply_toner_magenta" , 25.0 ),
208214 Result (state = State .OK , summary = "Supply: 25 of max. 100 micrometers" ),
209- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
210215 ],
211216 ),
212217 (
@@ -219,9 +224,8 @@ def test_inventory_printer_supply(
219224 ],
220225 ],
221226 [
222- Result (state = State .OK , summary = "Remaining: 25.00%" ),
223- Result (state = State .OK , summary = "Supply: 25 of max. 100" ),
224- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
227+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
228+ Metric ("supply_toner_magenta" , 25.0 ),
225229 ],
226230 ),
227231 (
@@ -234,9 +238,8 @@ def test_inventory_printer_supply(
234238 ],
235239 ],
236240 [
237- Result (state = State .OK , summary = "Remaining: 25.00%" ),
238- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
239- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
241+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
242+ Metric ("supply_toner_magenta" , 25.0 ),
240243 ],
241244 ),
242245 (
@@ -271,9 +274,8 @@ def test_inventory_printer_supply(
271274 ],
272275 ],
273276 [
274- Result (state = State .OK , summary = "Remaining: 25.00%" ),
275- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
276- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
277+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
278+ Metric ("supply_toner_magenta" , 25.0 ),
277279 ],
278280 ),
279281 (
@@ -287,9 +289,8 @@ def test_inventory_printer_supply(
287289 ],
288290 ],
289291 [
290- Result (state = State .OK , summary = "Remaining: 25.00%" ),
291- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
292- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
292+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
293+ Metric ("supply_toner_other" , 25.0 ),
293294 ],
294295 ),
295296 (
@@ -303,9 +304,8 @@ def test_inventory_printer_supply(
303304 ],
304305 ],
305306 [
306- Result (state = State .OK , summary = "Remaining: 25.00%" ),
307- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
308- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
307+ Result (state = State .OK , summary = "Supply level remaining: 25.00%" ),
308+ Metric ("supply_toner_magenta" , 25.0 ),
309309 ],
310310 ),
311311 (
@@ -318,9 +318,8 @@ def test_inventory_printer_supply(
318318 ],
319319 ],
320320 [
321- Result (state = State .OK , summary = "Remaining: 75.00%" ),
322- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
323- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
321+ Result (state = State .OK , summary = "Supply level remaining: 75.00%" ),
322+ Metric ("supply_toner_magenta" , 75.0 ),
324323 ],
325324 ),
326325 (
@@ -333,9 +332,8 @@ def test_inventory_printer_supply(
333332 ],
334333 ],
335334 [
336- Result (state = State .OK , summary = "Remaining: 75.00%" ),
337- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
338- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
335+ Result (state = State .OK , summary = "Supply level remaining: 75.00%" ),
336+ Metric ("supply_toner_magenta" , 75.0 ),
339337 ],
340338 ),
341339 (
@@ -348,9 +346,8 @@ def test_inventory_printer_supply(
348346 ],
349347 ],
350348 [
351- Result (state = State .OK , summary = "[magenta] Remaining: 75.00%" ),
352- Result (state = State .OK , summary = "Supply: 25 of max. 100%" ),
353- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
349+ Result (state = State .OK , summary = "Supply level remaining: 75.00%" ),
350+ Metric ("supply_toner_magenta" , 75.0 ),
354351 ],
355352 ),
356353 ],
@@ -364,3 +361,39 @@ def test_check_printer_supply(
364361 section = parse_printer_supply (info )
365362 result = check_printer_supply (item , params , section )
366363 assert list (result ) == expected_result
364+
365+
366+ def _get_section_with_color_in_description (item : str ) -> Section :
367+ max_capacity , supply_level , container_class = "0" , "25" , str (SupplyClass .CONTAINER )
368+ info = [[["1.1" , "" ]], [[item , "" , max_capacity , supply_level , container_class , "" ]]]
369+ return parse_printer_supply (info )
370+
371+
372+ @pytest .mark .parametrize ("item" , ["Black" , "Schwarz" , "Noir" , "Negra" ])
373+ def test_check_printer_supply_black_translations (item : str ) -> None :
374+ section = _get_section_with_color_in_description (item )
375+
376+ _ , value = list (check_printer_supply (item , DEFAULT_PARAMETERS , section ))
377+ expected = Metric ("supply_toner_black" , 25.0 )
378+
379+ assert value == expected
380+
381+
382+ @pytest .mark .parametrize ("item" , ["Cyan" , "Zyan" , "Cian" ])
383+ def test_check_printer_supply_cyan_translations (item : str ) -> None :
384+ section = _get_section_with_color_in_description (item )
385+
386+ _ , value = list (check_printer_supply (item , DEFAULT_PARAMETERS , section ))
387+ expected = Metric ("supply_toner_cyan" , 25.0 )
388+
389+ assert value == expected
390+
391+
392+ @pytest .mark .parametrize ("item" , ["Yellow" , "Gelb" , "Jaune" , "Amarilla" ])
393+ def test_check_printer_supply_yellow_translations (item : str ) -> None :
394+ section = _get_section_with_color_in_description (item )
395+
396+ _ , value = list (check_printer_supply (item , DEFAULT_PARAMETERS , section ))
397+ expected = Metric ("supply_toner_yellow" , 25.0 )
398+
399+ assert value == expected
0 commit comments