From f66f1a8f0c0be942b67777e5d87be64ad3f5faa3 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 11 Mar 2020 15:35:16 -0500 Subject: [PATCH] plugin tests: actually check log result + move over to '' -> true a few things. one is that `is_in_log` returns a result rather than enforcing a condition. so these lines all need asserts two is that with the 'allow_deprecated_apis' option on, the python json parser overwrites the now typed input with the later-added string version, so the only option value present in the option key-value set is the last, string one. the check for this has been updated to only verify that the string version is included (i manually verified that both are printed to the JSON message) --- tests/test_plugin.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 440b0dd4575c..0f3f0a304c27 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -58,9 +58,9 @@ def test_option_types(node_factory): 'bool_opt': True, }) - n.daemon.is_in_log(r"option str_opt ok ") - n.daemon.is_in_log(r"option int_opt 22 ") - n.daemon.is_in_log(r"option bool_opt True ") + assert n.daemon.is_in_log(r"option str_opt ok ") + assert n.daemon.is_in_log(r"option int_opt 22 ") + assert n.daemon.is_in_log(r"option bool_opt True ") n.stop() # A blank bool_opt should default to false @@ -70,7 +70,7 @@ def test_option_types(node_factory): 'bool_opt': '', }) - n.daemon.is_in_log(r"option bool_opt False ") + assert n.daemon.is_in_log(r"option bool_opt True ") n.stop() # What happens if we give it a bad bool-option? @@ -103,13 +103,15 @@ def test_option_types(node_factory): 'str_opt': 'ok', 'int_opt': 22, 'bool_opt': 1, + 'allow-deprecated-apis': True }) - n.daemon.is_in_log(r"option str_opt ok ") - n.daemon.is_in_log(r"option int_opt 22 ") - n.daemon.is_in_log(r"option int_opt 22 ") - n.daemon.is_in_log(r"option bool_opt True ") - n.daemon.is_in_log(r"option bool_opt true ") + # because of how the python json parser works, since we're adding the deprecated + # string option after the 'typed' option in the JSON, the string option overwrites + # the earlier typed option in JSON parsing, resulting in a option set of only strings + assert n.daemon.is_in_log(r"option str_opt ok ") + assert n.daemon.is_in_log(r"option int_opt 22 ") + assert n.daemon.is_in_log(r"option bool_opt 1 ") n.stop()