Skip to content

Commit 140c153

Browse files
committed
fix bug to support commands that don't take arguments; modify testing accordingly
1 parent 2eae505 commit 140c153

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

saomsg/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ async def run(self, command, *pars):
9191
if command not in self.server_info['registered']:
9292
errmsg = f"{command} not registered by MSG server {self.server_info['name']}"
9393
raise ValueError(errmsg)
94-
params = " ".join(str(x) for x in pars)
95-
msg = f"1 {command} {params}\n"
94+
if len(pars) > 0:
95+
params = " ".join(str(x) for x in pars)
96+
msg = f"1 {command} {params}\n"
97+
else:
98+
params = "<None>"
99+
msg = f"1 {command}\n"
96100
data = await self._writemsg(msg)
97101
if int(data[0]) == 1 and data[1] == "ack":
98102
value = True

saomsg/tests/test_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ async def test_get():
2828
async def test_cmd():
2929
c = MSGClient()
3030
await c.open()
31-
await c.run("multiply", 4, 5)
31+
status = await c.run("multiply", 4, 5)
32+
assert(status)
3233
foo = await c.get("foo")
3334
assert(int(foo) == 20)
35+
status = await c.run("blurb")
36+
assert(status)
3437
await c.close()
3538

3639

scripts/msg_test.tcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@ proc TESTSRV.multiply { s sock msgid cmd x y } {
2323
msg_ack $sock $msgid
2424
}
2525

26+
msg_register TESTSRV blurb
27+
proc TESTSRV.blurb { s sock msgid cmd } {
28+
msg_ack $sock $msgid
29+
}
30+
2631
msg_up TESTSRV
2732
vwait forever

0 commit comments

Comments
 (0)