|
@@ -17,23 +17,31 @@ class SinkTestCase(unittest.TestCase):
|
17
|
17
|
self.pdbs = pdbuddy.Sink(pdbs_devices[0])
|
18
|
18
|
|
19
|
19
|
self.obj_valid = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
20
|
|
- flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
|
|
20
|
+ flags=pdbuddy.SinkFlags.NONE, v=15000, vmin=None, vmax=None,
|
|
21
|
+ i=3000)
|
21
|
22
|
self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
22
|
|
- flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, i=3000)
|
|
23
|
+ flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, vmin=None,
|
|
24
|
+ vmax=None, i=3000)
|
23
|
25
|
|
24
|
26
|
self.obj_huge_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
25
|
|
- flags=pdbuddy.SinkFlags.NONE, v=65536, i=1000)
|
|
27
|
+ flags=pdbuddy.SinkFlags.NONE, v=65536, vmin=None, vmax=None,
|
|
28
|
+ i=1000)
|
26
|
29
|
self.obj_big_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
27
|
|
- flags=pdbuddy.SinkFlags.NONE, v=21001, i=1000)
|
|
30
|
+ flags=pdbuddy.SinkFlags.NONE, v=21001, vmin=None, vmax=None,
|
|
31
|
+ i=1000)
|
28
|
32
|
self.obj_neg_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
29
|
|
- flags=pdbuddy.SinkFlags.NONE, v=-1, i=1000)
|
|
33
|
+ flags=pdbuddy.SinkFlags.NONE, v=-1, vmin=None, vmax=None,
|
|
34
|
+ i=1000)
|
30
|
35
|
|
31
|
36
|
self.obj_huge_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
32
|
|
- flags=pdbuddy.SinkFlags.NONE, v=5000, i=65536)
|
|
37
|
+ flags=pdbuddy.SinkFlags.NONE, v=5000, vmin=None, vmax=None,
|
|
38
|
+ i=65536)
|
33
|
39
|
self.obj_big_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
34
|
|
- flags=pdbuddy.SinkFlags.NONE, v=5000, i=5001)
|
|
40
|
+ flags=pdbuddy.SinkFlags.NONE, v=5000, vmin=None, vmax=None,
|
|
41
|
+ i=5001)
|
35
|
42
|
self.obj_neg_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
36
|
|
- flags=pdbuddy.SinkFlags.NONE, v=5000, i=-1)
|
|
43
|
+ flags=pdbuddy.SinkFlags.NONE, v=5000, vmin=None, vmax=None,
|
|
44
|
+ i=-1)
|
37
|
45
|
|
38
|
46
|
def tearDown(self):
|
39
|
47
|
# Close the connection to the PD Buddy Sink
|
|
@@ -145,19 +153,30 @@ class SinkConfigTestCase(unittest.TestCase):
|
145
|
153
|
|
146
|
154
|
def setUp(self):
|
147
|
155
|
self.obj_none = pdbuddy.SinkConfig(status=None, flags=None, v=None,
|
148
|
|
- i=None)
|
|
156
|
+ vmin=None, vmax=None, i=None)
|
149
|
157
|
self.obj_empty = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.EMPTY,
|
150
|
|
- flags=None, v=None, i=None)
|
|
158
|
+ flags=None, v=None, vmin=None, vmax=None, i=None)
|
151
|
159
|
self.obj_valid = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
152
|
|
- flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
|
|
160
|
+ flags=pdbuddy.SinkFlags.NONE, v=15000, vmin=None, vmax=None,
|
|
161
|
+ i=3000)
|
153
|
162
|
self.obj_invalid = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.INVALID,
|
154
|
|
- flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
|
|
163
|
+ flags=pdbuddy.SinkFlags.NONE, v=15000, vmin=None, vmax=None,
|
|
164
|
+ i=3000)
|
155
|
165
|
self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
156
|
|
- flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, i=3000)
|
|
166
|
+ flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, vmin=None,
|
|
167
|
+ vmax=None, i=3000)
|
157
|
168
|
self.obj_valid_5v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
158
|
|
- flags=pdbuddy.SinkFlags.NONE, v=5000, i=3000)
|
|
169
|
+ flags=pdbuddy.SinkFlags.NONE, v=5000, vmin=None, vmax=None,
|
|
170
|
+ i=3000)
|
159
|
171
|
self.obj_valid_1a = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
160
|
|
- flags=pdbuddy.SinkFlags.NONE, v=15000, i=1000)
|
|
172
|
+ flags=pdbuddy.SinkFlags.NONE, v=15000, vmin=None, vmax=None,
|
|
173
|
+ i=1000)
|
|
174
|
+ self.obj_valid_range = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
|
175
|
+ flags=pdbuddy.SinkFlags.NONE, v=15000, vmin=12000, vmax=16000,
|
|
176
|
+ i=1000)
|
|
177
|
+ self.obj_valid_hv = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
|
|
178
|
+ flags=pdbuddy.SinkFlags.HV_PREFERRED, v=15000, vmin=12000,
|
|
179
|
+ vmax=16000, i=1000)
|
161
|
180
|
|
162
|
181
|
def test_str_none(self):
|
163
|
182
|
self.assertEqual(str(self.obj_none), "No configuration")
|
|
@@ -167,23 +186,33 @@ class SinkConfigTestCase(unittest.TestCase):
|
167
|
186
|
|
168
|
187
|
def test_str_valid(self):
|
169
|
188
|
self.assertEqual(str(self.obj_valid),
|
170
|
|
- "status: valid\nflags: (none)\nv: 15.00 V\ni: 3.00 A")
|
|
189
|
+ "status: valid\nflags: (none)\nv: 15.000 V\ni: 3.00 A")
|
171
|
190
|
|
172
|
191
|
def test_str_invalid(self):
|
173
|
192
|
self.assertEqual(str(self.obj_invalid),
|
174
|
|
- "status: invalid\nflags: (none)\nv: 15.00 V\ni: 3.00 A")
|
|
193
|
+ "status: invalid\nflags: (none)\nv: 15.000 V\ni: 3.00 A")
|
175
|
194
|
|
176
|
195
|
def test_str_valid_gb(self):
|
177
|
196
|
self.assertEqual(str(self.obj_valid_gb),
|
178
|
|
- "status: valid\nflags: GiveBack\nv: 15.00 V\ni: 3.00 A")
|
|
197
|
+ "status: valid\nflags: GiveBack\nv: 15.000 V\ni: 3.00 A")
|
179
|
198
|
|
180
|
199
|
def test_str_valid_5v(self):
|
181
|
200
|
self.assertEqual(str(self.obj_valid_5v),
|
182
|
|
- "status: valid\nflags: (none)\nv: 5.00 V\ni: 3.00 A")
|
|
201
|
+ "status: valid\nflags: (none)\nv: 5.000 V\ni: 3.00 A")
|
183
|
202
|
|
184
|
203
|
def test_str_valid_1a(self):
|
185
|
204
|
self.assertEqual(str(self.obj_valid_1a),
|
186
|
|
- "status: valid\nflags: (none)\nv: 15.00 V\ni: 1.00 A")
|
|
205
|
+ "status: valid\nflags: (none)\nv: 15.000 V\ni: 1.00 A")
|
|
206
|
+
|
|
207
|
+ def test_str_valid_range(self):
|
|
208
|
+ self.assertEqual(str(self.obj_valid_range),
|
|
209
|
+ "status: valid\nflags: (none)\nv: 15.000 V\nvmin: 12.000 V\n"
|
|
210
|
+ "vmax: 16.000 V\ni: 1.00 A")
|
|
211
|
+
|
|
212
|
+ def test_str_valid_hv(self):
|
|
213
|
+ self.assertEqual(str(self.obj_valid_hv),
|
|
214
|
+ "status: valid\nflags: HV_Preferred\nv: 15.000 V\n"
|
|
215
|
+ "vmin: 12.000 V\nvmax: 16.000 V\ni: 1.00 A")
|
187
|
216
|
|
188
|
217
|
def test_from_text_none(self):
|
189
|
218
|
ft_none = pdbuddy.SinkConfig.from_text([])
|
|
@@ -196,38 +225,56 @@ class SinkConfigTestCase(unittest.TestCase):
|
196
|
225
|
def test_from_text_valid(self):
|
197
|
226
|
ft_valid = pdbuddy.SinkConfig.from_text([b"status: valid",
|
198
|
227
|
b"flags: (none)",
|
199
|
|
- b"v: 15.00 V",
|
|
228
|
+ b"v: 15.000 V",
|
200
|
229
|
b"i: 3.00 A"])
|
201
|
230
|
self.assertEqual(ft_valid, self.obj_valid)
|
202
|
231
|
|
203
|
232
|
def test_from_text_invalid(self):
|
204
|
233
|
ft_invalid = pdbuddy.SinkConfig.from_text([b"status: invalid",
|
205
|
234
|
b"flags: (none)",
|
206
|
|
- b"v: 15.00 V",
|
|
235
|
+ b"v: 15.000 V",
|
207
|
236
|
b"i: 3.00 A"])
|
208
|
237
|
self.assertEqual(ft_invalid, self.obj_invalid)
|
209
|
238
|
|
210
|
239
|
def test_from_text_valid_gb(self):
|
211
|
240
|
ft_valid_gb = pdbuddy.SinkConfig.from_text([b"status: valid",
|
212
|
241
|
b"flags: GiveBack",
|
213
|
|
- b"v: 15.00 V",
|
|
242
|
+ b"v: 15.000 V",
|
214
|
243
|
b"i: 3.00 A"])
|
215
|
244
|
self.assertEqual(ft_valid_gb, self.obj_valid_gb)
|
216
|
245
|
|
217
|
246
|
def test_from_text_valid_5v(self):
|
218
|
247
|
ft_valid_5v = pdbuddy.SinkConfig.from_text([b"status: valid",
|
219
|
248
|
b"flags: (none)",
|
220
|
|
- b"v: 5.00 V",
|
|
249
|
+ b"v: 5.000 V",
|
221
|
250
|
b"i: 3.00 A"])
|
222
|
251
|
self.assertEqual(ft_valid_5v, self.obj_valid_5v)
|
223
|
252
|
|
224
|
253
|
def test_from_text_valid_1a(self):
|
225
|
254
|
ft_valid_1a = pdbuddy.SinkConfig.from_text([b"status: valid",
|
226
|
255
|
b"flags: (none)",
|
227
|
|
- b"v: 15.00 V",
|
|
256
|
+ b"v: 15.000 V",
|
228
|
257
|
b"i: 1.00 A"])
|
229
|
258
|
self.assertEqual(ft_valid_1a, self.obj_valid_1a)
|
230
|
259
|
|
|
260
|
+ def test_from_text_valid_range(self):
|
|
261
|
+ ft_valid_range = pdbuddy.SinkConfig.from_text([b"status: valid",
|
|
262
|
+ b"flags: (none)",
|
|
263
|
+ b"v: 15.000 V",
|
|
264
|
+ b"vmin: 12.000 V",
|
|
265
|
+ b"vmax: 16.000 V",
|
|
266
|
+ b"i: 1.00 A"])
|
|
267
|
+ self.assertEqual(ft_valid_range, self.obj_valid_range)
|
|
268
|
+
|
|
269
|
+ def test_from_text_valid_hv(self):
|
|
270
|
+ ft_valid_hv = pdbuddy.SinkConfig.from_text([b"status: valid",
|
|
271
|
+ b"flags: HV_Preferred",
|
|
272
|
+ b"v: 15.000 V",
|
|
273
|
+ b"vmin: 12.000 V",
|
|
274
|
+ b"vmax: 16.000 V",
|
|
275
|
+ b"i: 1.00 A"])
|
|
276
|
+ self.assertEqual(ft_valid_hv, self.obj_valid_hv)
|
|
277
|
+
|
231
|
278
|
def test_from_text_invalid_index(self):
|
232
|
279
|
with self.assertRaises(IndexError):
|
233
|
280
|
pdbuddy.SinkConfig.from_text([b"Invalid index"])
|
|
@@ -240,7 +287,7 @@ class SinkConfigTestCase(unittest.TestCase):
|
240
|
287
|
ft_valid = pdbuddy.SinkConfig.from_text([b"status: valid",
|
241
|
288
|
b"flags: (none)",
|
242
|
289
|
b"This is an extra line, which shouldn't hurt anything.",
|
243
|
|
- b"v: 15.00 V",
|
|
290
|
+ b"v: 15.000 V",
|
244
|
291
|
b"i: 3.00 A"])
|
245
|
292
|
self.assertEqual(ft_valid, self.obj_valid)
|
246
|
293
|
|