Client tests: --version dummy, and float printing for sub.

pull/2624/head
Roger A. Light 3 years ago
parent 7370a7d028
commit 7ec8417e54

@ -29,8 +29,9 @@ def do_test(args, stderr_expected, rc_expected):
if __name__ == '__main__':
helps = "\nUse 'mosquitto_sub --help' to see usage.\n"
# Usage, ignore actual text though.
# Usage and version, ignore actual text though.
do_test(['--help'], None, 1)
do_test(['--version'], None, 1)
# Missing args
do_test(['-A'], "Error: -A argument given but no address specified.\n\n" + helps, 1)

@ -4,7 +4,7 @@
from mosq_test_helper import *
def do_test(format_str, expected_output, proto_ver=4):
def do_test(format_str, expected_output, proto_ver=4, payload="message"):
rc = 1
port = mosq_test.get_port()
@ -32,7 +32,6 @@ def do_test(format_str, expected_output, proto_ver=4):
if proto_ver == 5:
cmd += ['-D', 'subscribe', 'subscription-identifier', '56']
payload = "message"
props = mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 1)
props += mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_MESSAGE_EXPIRY_INTERVAL, 3600)
props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CONTENT_TYPE, "plain/text")
@ -126,3 +125,5 @@ do_test('\\t', '\t\n')
do_test('\\v', '\v\n')
do_test('@@', '@\n')
do_test('text', 'text\n')
do_test('%.3d', '2.718\n', payload=struct.pack('BBBBBBBB', 0x58, 0x39, 0xB4, 0xC8, 0x76, 0xBE, 0x05, 0x40))
do_test('%.3f', '0.707\n', payload=struct.pack('BBBB', 0xF4, 0xFD, 0x34, 0x3F))

@ -29,9 +29,10 @@ def do_test(args, stderr_expected, rc_expected):
if __name__ == '__main__':
helps = "\nUse 'mosquitto_pub --help' to see usage.\n"
# Usage, ignore actual text though.
# Usage, version, ignore actual text though.
do_test(['--help'], None, 1)
do_test(['--version'], None, 1)
# Missing args
do_test(['-A'], "Error: -A argument given but no address specified.\n\n" + helps, 1)
do_test(['-f'], "Error: -f argument given but no file specified.\n\n" + helps, 1)

@ -27,8 +27,9 @@ def do_test(args, stderr_expected, rc_expected):
if __name__ == '__main__':
helps = "\nUse 'mosquitto_rr --help' to see usage.\n"
# Usage, ignore actual text though.
# Usage, version, ignore actual text though.
do_test(['--help'], None, 1)
do_test(['--version'], None, 1)
# Missing args
do_test(['-A'], "Error: -A argument given but no address specified.\n\n" + helps, 1)

@ -626,7 +626,8 @@ def gen_publish(topic, qos, payload=None, retain=False, dup=False, mid=0, proto_
pack_format = pack_format + "%ds"%(len(properties))
if payload != None:
payload = payload.encode("utf-8")
if isinstance(payload, bytes) == False:
payload = payload.encode("utf-8")
rl = rl + len(payload)
pack_format = pack_format + str(len(payload))+"s"
else:

Loading…
Cancel
Save