Skip to content

Commit 6f8a9e1

Browse files
committed
Return True, not 'OK'.
Updated tests to match.
1 parent 6aaf952 commit 6f8a9e1

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

nut2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,12 @@ def set_var(self, ups="", var="", value=""):
276276
The variable must be a writable value (cf list_rw_vars) and you
277277
must have the proper rights to set it (maybe login/password).
278278
"""
279+
logging.debug("set_var '%s' from '%s' to '%s'", var, ups, value)
279280

280281
self._srv_handler.write("SET VAR %s %s %s\n" % (ups, var, value))
281282
result = self._srv_handler.read_until("\n")
282283
if result == "OK\n":
283-
return "OK"
284+
return True
284285
else:
285286
raise PyNUTError(result)
286287

@@ -295,7 +296,7 @@ def run_command(self, ups="", command=""):
295296
self._srv_handler.write("INSTCMD %s %s\n" % (ups, command))
296297
result = self._srv_handler.read_until("\n")
297298
if result == "OK\n":
298-
return "OK"
299+
return True
299300
else:
300301
raise PyNUTError(result.replace("\n", ""))
301302

@@ -316,7 +317,7 @@ def fsd(self, ups=""):
316317
self._srv_handler.write("FSD %s\n" % ups)
317318
result = self._srv_handler.read_until("\n")
318319
if result == "OK FSD-SET\n":
319-
return "OK"
320+
return True
320321
else:
321322
raise PyNUTError(result.replace("\n", ""))
322323

tests/testclient.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def test_get_rw_vars_invalid_ups(self):
118118
self.assertRaises(PyNUTError, self.client.list_rw_vars, self.invalid)
119119

120120
def test_set_rw_var_valid(self):
121-
self.assertEquals(self.client.set_var(self.valid, self.valid,
122-
self.valid), 'OK')
121+
assert(self.client.set_var(self.valid, self.valid, self.valid))
123122

124123
def test_set_rw_var_invalid(self):
125124
self.assertRaises(PyNUTError, self.client.set_var, self.invalid,
@@ -130,8 +129,7 @@ def test_set_rw_var_broken(self):
130129
self.valid, self.valid)
131130

132131
def test_run_ups_command_valid(self):
133-
self.assertEquals(self.client.run_command(self.valid,
134-
self.valid), 'OK')
132+
assert(self.client.run_command(self.valid, self.valid))
135133

136134
def test_run_ups_command_invalid(self):
137135
self.assertRaises(PyNUTError, self.client.run_command, self.invalid,
@@ -142,7 +140,7 @@ def test_run_ups_command_broken(self):
142140
self.valid)
143141

144142
def test_fsd_valid_ups(self):
145-
self.assertEquals(self.client.fsd(self.valid), 'OK')
143+
assert(self.client.fsd(self.valid))
146144

147145
def test_fsd_invalid_ups(self):
148146
self.assertRaises(PyNUTError, self.client.fsd, self.invalid)

0 commit comments

Comments
 (0)