From d80767f1c4fc3195dd3327369496a5c88449f375 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 1 Aug 2016 21:35:47 +0100 Subject: [PATCH] Added string list settings to pyhton test --- tests/python-test.py | 97 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/tests/python-test.py b/tests/python-test.py index 6d22169..486bf26 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -267,6 +267,54 @@ def _string(op, group, key, value): prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + value) +def _string_list(op, group, key, value): + if op != "get" and op != "add" and op !="remove" and op != "remove_all": + prof.cons_bad_cmd_usage("/python-test") + return + + if op == "get": + if group == None or key == None: + prof.cons_bad_cmd_usage("/python-test") + return + res = prof.settings_get_string_list(group, key) + prof.win_focus(plugin_win) + if res is None: + prof.win_show(plugin_win, "No list found") + return + prof.win_show(plugin_win, "String list:") + for el in res: + prof.win_show(plugin_win, " " + el) + return + + if op == "add": + if group == None or key == None or value == None: + prof.cons_bad_cmd_usage("/python-test") + return + prof.settings_string_list_add(group, key, value) + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "Added '" + value + "' to [" + group + "]" + " " + key) + + + if op == "remove": + if group == None or key == None or value == None: + prof.cons_bad_cmd_usage("/python-test") + return + res = prof.settings_string_list_remove(group, key, value) + prof.win_focus(plugin_win) + if res: + prof.win_show(plugin_win, "Removed '" + value + "' to [" + group + "]" + " " + key) + else: + prof.win_show(plugin_win, "Error removing string item from list") + + if op == "remove_all": + if group == None or key == None: + prof.cons_bad_cmd_usage("/python-test") + return + prof.settings_string_list_remove_all(group, key) + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "Removed all items from [" + group + "]" + " " + key) + + def _int(op, group, key, value): if op != "get" and op != "set": prof.cons_bad_cmd_usage("/python-test") @@ -318,24 +366,25 @@ def _completer(op, item): def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None): - if subcmd == "consalert": _consalert() - elif subcmd == "consshow": _consshow(arg1) - elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4) - elif subcmd == "constest": _constest() - elif subcmd == "winshow": _winshow(arg1) - elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4) - elif subcmd == "sendline": _sendline(arg1) - elif subcmd == "notify": _notify(arg1) - elif subcmd == "get": _get(arg1) - elif subcmd == "log": _log(arg1, arg2) - elif subcmd == "count": _count() - elif subcmd == "ping": _ping(arg1) - elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4) - elif subcmd == "string": _string(arg1, arg2, arg3, arg4) - elif subcmd == "int": _int(arg1, arg2, arg3, arg4) - elif subcmd == "incoming": _incoming(arg1, arg2, arg3) - elif subcmd == "completer": _completer(arg1, arg2) - else: prof.cons_bad_cmd_usage("/python-test") + if subcmd == "consalert": _consalert() + elif subcmd == "consshow": _consshow(arg1) + elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4) + elif subcmd == "constest": _constest() + elif subcmd == "winshow": _winshow(arg1) + elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4) + elif subcmd == "sendline": _sendline(arg1) + elif subcmd == "notify": _notify(arg1) + elif subcmd == "get": _get(arg1) + elif subcmd == "log": _log(arg1, arg2) + elif subcmd == "count": _count() + elif subcmd == "ping": _ping(arg1) + elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4) + elif subcmd == "string": _string(arg1, arg2, arg3, arg4) + elif subcmd == "string_list": _string_list(arg1, arg2, arg3, arg4) + elif subcmd == "int": _int(arg1, arg2, arg3, arg4) + elif subcmd == "incoming": _incoming(arg1, arg2, arg3) + elif subcmd == "completer": _completer(arg1, arg2) + else: prof.cons_bad_cmd_usage("/python-test") def timed_callback(): @@ -381,6 +430,10 @@ def prof_init(version, status, account_name, fulljid): "/python-test boolean set ", "/python-test string get ", "/python-test string set ", + "/python-test string_list get ", + "/python-test string_list add ", + "/python-test string_list remove ", + "/python-test string_list remove_all ", "/python-test int get ", "/python-test int set ", "/python-test incoming ", @@ -407,6 +460,10 @@ def prof_init(version, status, account_name, fulljid): [ "boolean set ", "Set a boolean setting" ], [ "string get ", "Get a string setting" ], [ "string set ", "Set a string setting" ], + [ "string_list get ", "Get a string list setting" ], + [ "string_list add ", "Add a string to a string list setting" ], + [ "string_list remove ", "Remove a string from a string list setting" ], + [ "string_list remove_all ", "Remove all strings from a string list setting" ], [ "int get ", "Get a integer setting" ], [ "int set ", "Set a integer setting" ], [ "incoming ", "Show an incoming message." ], @@ -439,6 +496,7 @@ def prof_init(version, status, account_name, fulljid): "ping", "boolean", "string", + "string_list", "int", "incoming", "completer" @@ -456,6 +514,9 @@ def prof_init(version, status, account_name, fulljid): prof.completer_add("/python-test string", [ "get", "set" ] ) + prof.completer_add("/python-test string_list", + [ "get", "add", "remove", "remove_all" ] + ) prof.completer_add("/python-test int", [ "get", "set" ] )