Selaa lähdekoodia

Added tests for invalid voltages and currents

Added three new tests: test_set_tmpcfg_huge, test_set_tmpcfg_big, and
test_set_tmpcfg_neg.  They set temporary configurations with huge
(> UINT16_MAX), big (> 20 V, > 5 A), and negative voltages and currents,
respectively.  These tests all fail currently, so I'll work on making
them pass.
Clara Hobbs 7 vuotta sitten
vanhempi
commit
8791797070
1 muutettua tiedostoa jossa 18 lisäystä ja 0 poistoa
  1. 18
    0
      test_pdbuddy/__init__.py

+ 18
- 0
test_pdbuddy/__init__.py Näytä tiedosto

@@ -20,6 +20,12 @@ class SinkTestCase(unittest.TestCase):
20 20
                 flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
21 21
         self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
22 22
                 flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, i=3000)
23
+        self.obj_huge_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
24
+                flags=pdbuddy.SinkFlags.NONE, v=70000, i=70000)
25
+        self.obj_big_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
26
+                flags=pdbuddy.SinkFlags.NONE, v=50000, i=50000)
27
+        self.obj_neg_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
28
+                flags=pdbuddy.SinkFlags.NONE, v=-5000, i=-1000)
23 29
 
24 30
     def tearDown(self):
25 31
         # Close the connection to the PD Buddy Sink
@@ -46,6 +52,18 @@ class SinkTestCase(unittest.TestCase):
46 52
         self.pdbs.set_tmpcfg(self.obj_valid_gb)
47 53
         self.assertEqual(self.pdbs.get_tmpcfg(), self.obj_valid_gb)
48 54
 
55
+    def test_set_tmpcfg_huge_vi(self):
56
+        with self.assertRaises(ValueError):
57
+            self.pdbs.set_tmpcfg(self.obj_huge_vi)
58
+
59
+    def test_set_tmpcfg_big_vi(self):
60
+        with self.assertRaises(ValueError):
61
+            self.pdbs.set_tmpcfg(self.obj_big_vi)
62
+
63
+    def test_set_tmpcfg_neg_vi(self):
64
+        with self.assertRaises(ValueError):
65
+            self.pdbs.set_tmpcfg(self.obj_neg_vi)
66
+
49 67
     def test_write(self):
50 68
         self.test_set_tmpcfg_valid()
51 69
         self.pdbs.write()

Loading…
Peruuta
Tallenna