|
@@ -319,6 +319,10 @@ class ReadPDOTestCase(unittest.TestCase):
|
319
|
319
|
rp_unknown_notzero = pdbuddy.read_pdo([b"PDO 1: FFFFFFFF"])
|
320
|
320
|
self.assertEqual(self.unknown_notzero, rp_unknown_notzero)
|
321
|
321
|
|
|
322
|
+ def test_read_none(self):
|
|
323
|
+ none_pdo = pdbuddy.read_pdo([b"No Source_Capabilities"])
|
|
324
|
+ self.assertEqual(none_pdo, None)
|
|
325
|
+
|
322
|
326
|
|
323
|
327
|
class ReadPDOListTestCase(unittest.TestCase):
|
324
|
328
|
|
|
@@ -353,3 +357,114 @@ class ReadPDOListTestCase(unittest.TestCase):
|
353
|
357
|
self.assertEqual(pdo_list[1], self.src_fixed_minimal)
|
354
|
358
|
self.assertEqual(pdo_list[2], self.unknown_zero)
|
355
|
359
|
self.assertEqual(pdo_list[3], self.unknown_notzero)
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+class PDOListCalculationsTestCase(unittest.TestCase):
|
|
363
|
+
|
|
364
|
+ def setUp(self):
|
|
365
|
+ self.src_fixed_5v_1p5a = pdbuddy.SrcFixedPDO(False, False, True,
|
|
366
|
+ False, False, 0, 5000, 1500)
|
|
367
|
+ self.src_fixed_5v_3a = pdbuddy.SrcFixedPDO(False, False, True, False,
|
|
368
|
+ False, 0, 5000, 3000)
|
|
369
|
+ self.src_fixed_9v_1p6a = pdbuddy.SrcFixedPDO(False, False, False,
|
|
370
|
+ False, False, 0, 9000, 1600)
|
|
371
|
+ self.src_fixed_9v_3a = pdbuddy.SrcFixedPDO(False, False, False, False,
|
|
372
|
+ False, 0, 9000, 3000)
|
|
373
|
+ self.src_fixed_10v_1p5a = pdbuddy.SrcFixedPDO(False, False, False,
|
|
374
|
+ False, False, 0, 10000, 1500)
|
|
375
|
+ self.src_fixed_12v_5a = pdbuddy.SrcFixedPDO(False, False, False, False,
|
|
376
|
+ False, 0, 12000, 5000)
|
|
377
|
+ self.src_fixed_15v_1p8a = pdbuddy.SrcFixedPDO(False, False, False,
|
|
378
|
+ False, False, 0, 15000, 1800)
|
|
379
|
+ self.src_fixed_15v_3a = pdbuddy.SrcFixedPDO(False, False, False, False,
|
|
380
|
+ False, 0, 15000, 3000)
|
|
381
|
+ self.src_fixed_20v_2p25a = pdbuddy.SrcFixedPDO(False, False, False,
|
|
382
|
+ False, False, 0, 20000, 2250)
|
|
383
|
+ self.src_fixed_20v_5a = pdbuddy.SrcFixedPDO(False, False, False, False,
|
|
384
|
+ False, 0, 20000, 5000)
|
|
385
|
+
|
|
386
|
+ def test_calculate_pdp_15w(self):
|
|
387
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a]), 15)
|
|
388
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
389
|
+ self.src_fixed_9v_1p6a]), 15)
|
|
390
|
+
|
|
391
|
+ def test_calculate_pdp_27w(self):
|
|
392
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
393
|
+ self.src_fixed_9v_3a]), 27)
|
|
394
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
395
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_1p8a]), 27)
|
|
396
|
+
|
|
397
|
+ def test_calculate_pdp_45w(self):
|
|
398
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
399
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a]), 45)
|
|
400
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
401
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a,
|
|
402
|
+ self.src_fixed_20v_2p25a]), 45)
|
|
403
|
+
|
|
404
|
+ def test_calculate_pdp_100w(self):
|
|
405
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_3a,
|
|
406
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a,
|
|
407
|
+ self.src_fixed_20v_5a]), 100)
|
|
408
|
+ self.assertEqual(pdbuddy.calculate_pdp([self.src_fixed_5v_1p5a,
|
|
409
|
+ self.src_fixed_12v_5a, self.src_fixed_20v_5a]), 100)
|
|
410
|
+
|
|
411
|
+ def test_follows_power_rules_true(self):
|
|
412
|
+ # <= 15 W
|
|
413
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a]))
|
|
414
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a]))
|
|
415
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
416
|
+ self.src_fixed_9v_1p6a]))
|
|
417
|
+ # <= 27 W
|
|
418
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
419
|
+ self.src_fixed_9v_3a]))
|
|
420
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
421
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_1p8a]))
|
|
422
|
+ # <= 45 W
|
|
423
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
424
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a]))
|
|
425
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
426
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a,
|
|
427
|
+ self.src_fixed_20v_2p25a]))
|
|
428
|
+ # <= 100 W
|
|
429
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
430
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a,
|
|
431
|
+ self.src_fixed_20v_5a]))
|
|
432
|
+ self.assertTrue(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
433
|
+ self.src_fixed_9v_3a, self.src_fixed_10v_1p5a,
|
|
434
|
+ self.src_fixed_12v_5a, self.src_fixed_15v_3a,
|
|
435
|
+ self.src_fixed_20v_5a]))
|
|
436
|
+
|
|
437
|
+ def test_follows_power_rules_false(self):
|
|
438
|
+ # <= 15 W
|
|
439
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_10v_1p5a]))
|
|
440
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a,
|
|
441
|
+ self.src_fixed_10v_1p5a]))
|
|
442
|
+ # <= 27 W
|
|
443
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_9v_3a]))
|
|
444
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a,
|
|
445
|
+ self.src_fixed_9v_3a]))
|
|
446
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
447
|
+ self.src_fixed_9v_1p6a, self.src_fixed_15v_1p8a]))
|
|
448
|
+ # <= 45 W
|
|
449
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_20v_2p25a]))
|
|
450
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a,
|
|
451
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a]))
|
|
452
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
453
|
+ self.src_fixed_9v_1p6a, self.src_fixed_15v_3a]))
|
|
454
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
455
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_1p8a,
|
|
456
|
+ self.src_fixed_20v_2p25a]))
|
|
457
|
+ # <= 100 W
|
|
458
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_20v_5a]))
|
|
459
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_1p5a,
|
|
460
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_3a,
|
|
461
|
+ self.src_fixed_20v_5a]))
|
|
462
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
463
|
+ self.src_fixed_9v_1p6a, self.src_fixed_15v_3a,
|
|
464
|
+ self.src_fixed_20v_5a]))
|
|
465
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
466
|
+ self.src_fixed_9v_3a, self.src_fixed_15v_1p8a,
|
|
467
|
+ self.src_fixed_20v_5a]))
|
|
468
|
+ self.assertFalse(pdbuddy.follows_power_rules([self.src_fixed_5v_3a,
|
|
469
|
+ self.src_fixed_9v_3a, self.src_fixed_12v_5a,
|
|
470
|
+ self.src_fixed_15v_3a, self.src_fixed_20v_2p25a]))
|