Browse Source

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 years ago
parent
commit
8791797070
1 changed files with 18 additions and 0 deletions
  1. 18
    0
      test_pdbuddy/__init__.py

+ 18
- 0
test_pdbuddy/__init__.py View File

20
                 flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
20
                 flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
21
         self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
21
         self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
22
                 flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, i=3000)
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
     def tearDown(self):
30
     def tearDown(self):
25
         # Close the connection to the PD Buddy Sink
31
         # Close the connection to the PD Buddy Sink
46
         self.pdbs.set_tmpcfg(self.obj_valid_gb)
52
         self.pdbs.set_tmpcfg(self.obj_valid_gb)
47
         self.assertEqual(self.pdbs.get_tmpcfg(), self.obj_valid_gb)
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
     def test_write(self):
67
     def test_write(self):
50
         self.test_set_tmpcfg_valid()
68
         self.test_set_tmpcfg_valid()
51
         self.pdbs.write()
69
         self.pdbs.write()

Loading…
Cancel
Save