Skip to content

Commit

Permalink
plugin tests: actually check log result + move over to '' -> true
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
niftynei committed Mar 11, 2020
1 parent 56be69a commit f66f1a8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def test_option_types(node_factory):
'bool_opt': True,
})

n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
n.daemon.is_in_log(r"option int_opt 22 <class 'int'>")
n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
assert n.daemon.is_in_log(r"option str_opt ok <class 'str'>")
assert n.daemon.is_in_log(r"option int_opt 22 <class 'int'>")
assert n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
n.stop()

# A blank bool_opt should default to false
Expand All @@ -70,7 +70,7 @@ def test_option_types(node_factory):
'bool_opt': '',
})

n.daemon.is_in_log(r"option bool_opt False <class 'bool'>")
assert n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
n.stop()

# What happens if we give it a bad bool-option?
Expand Down Expand Up @@ -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 <class 'str'>")
n.daemon.is_in_log(r"option int_opt 22 <class 'int'>")
n.daemon.is_in_log(r"option int_opt 22 <class 'str'>")
n.daemon.is_in_log(r"option bool_opt True <class 'bool'>")
n.daemon.is_in_log(r"option bool_opt true <class 'str'>")
# 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 <class 'str'>")
assert n.daemon.is_in_log(r"option int_opt 22 <class 'str'>")
assert n.daemon.is_in_log(r"option bool_opt 1 <class 'str'>")
n.stop()


Expand Down

0 comments on commit f66f1a8

Please sign in to comment.