@@ -143,7 +143,10 @@ def test_inventory_printer_supply(
143
143
["Magenta Ink Cartridge" , "15" , "-2" , "5" , "3" , "1" ],
144
144
],
145
145
],
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
+ ],
147
150
),
148
151
(
149
152
"Magenta Ink Cartridge" ,
@@ -156,10 +159,11 @@ def test_inventory_printer_supply(
156
159
],
157
160
[
158
161
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%)" ,
160
164
),
165
+ Metric ("supply_toner_magenta" , 5.0 ),
161
166
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 )),
163
167
],
164
168
),
165
169
(
@@ -173,10 +177,11 @@ def test_inventory_printer_supply(
173
177
],
174
178
[
175
179
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%)" ,
177
182
),
183
+ Metric ("supply_toner_magenta" , 15.0 ),
178
184
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 )),
180
185
],
181
186
),
182
187
(
@@ -189,9 +194,9 @@ def test_inventory_printer_supply(
189
194
],
190
195
],
191
196
[
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 ),
193
199
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 )),
195
200
],
196
201
),
197
202
(
@@ -204,9 +209,9 @@ def test_inventory_printer_supply(
204
209
],
205
210
],
206
211
[
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 ),
208
214
Result (state = State .OK , summary = "Supply: 25 of max. 100 micrometers" ),
209
- Metric ("pages" , 25 , levels = (20.0 , 10.0 ), boundaries = (0 , 100 )),
210
215
],
211
216
),
212
217
(
@@ -219,9 +224,8 @@ def test_inventory_printer_supply(
219
224
],
220
225
],
221
226
[
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 ),
225
229
],
226
230
),
227
231
(
@@ -234,9 +238,8 @@ def test_inventory_printer_supply(
234
238
],
235
239
],
236
240
[
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 ),
240
243
],
241
244
),
242
245
(
@@ -271,9 +274,8 @@ def test_inventory_printer_supply(
271
274
],
272
275
],
273
276
[
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 ),
277
279
],
278
280
),
279
281
(
@@ -287,9 +289,8 @@ def test_inventory_printer_supply(
287
289
],
288
290
],
289
291
[
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 ),
293
294
],
294
295
),
295
296
(
@@ -303,9 +304,8 @@ def test_inventory_printer_supply(
303
304
],
304
305
],
305
306
[
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 ),
309
309
],
310
310
),
311
311
(
@@ -318,9 +318,8 @@ def test_inventory_printer_supply(
318
318
],
319
319
],
320
320
[
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 ),
324
323
],
325
324
),
326
325
(
@@ -333,9 +332,8 @@ def test_inventory_printer_supply(
333
332
],
334
333
],
335
334
[
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 ),
339
337
],
340
338
),
341
339
(
@@ -348,9 +346,8 @@ def test_inventory_printer_supply(
348
346
],
349
347
],
350
348
[
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 ),
354
351
],
355
352
),
356
353
],
@@ -364,3 +361,39 @@ def test_check_printer_supply(
364
361
section = parse_printer_supply (info )
365
362
result = check_printer_supply (item , params , section )
366
363
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