Browse Source

Added exception-raising code to fix failing tests

Added code to set_v and set_i to check if the Sink gave any error
message when running those commands, raising exceptions if it did.
This makes two of the three new tests pass.  The other one will need
support from the Sink itself, which currently doesn't care if the
voltage is over 20 V or the current is over 5 A.  That is to say that
the third test will automatically start passing if the Sink is running
firmware 1.0.1, which is yet to be released.
Clara Hobbs 6 years ago
parent
commit
6bc2abe0b3
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      pdbuddy/__init__.py

+ 10
- 2
pdbuddy/__init__.py View File

131
 
131
 
132
     def set_v(self, mv):
132
     def set_v(self, mv):
133
         """Sets the voltage of the configuration buffer, in millivolts"""
133
         """Sets the voltage of the configuration buffer, in millivolts"""
134
-        self.send_command("set_v {}".format(mv))
134
+        out = self.send_command("set_v {}".format(mv))
135
+        # If that command gave any output, that indicates an error.  Raise an
136
+        # exception to make that clear.
137
+        if len(out):
138
+            raise ValueError(out[0])
135
 
139
 
136
     def set_i(self, ma):
140
     def set_i(self, ma):
137
         """Sets the current of the configuration buffer, in milliamperes"""
141
         """Sets the current of the configuration buffer, in milliamperes"""
138
-        self.send_command("set_i {}".format(ma))
142
+        out = self.send_command("set_i {}".format(ma))
143
+        # If that command gave any output, that indicates an error.  Raise an
144
+        # exception to make that clear.
145
+        if len(out):
146
+            raise ValueError(out[0])
139
 
147
 
140
     def identify(self):
148
     def identify(self):
141
         """Blinks the LED quickly"""
149
         """Blinks the LED quickly"""

Loading…
Cancel
Save