From c62293103e97fd36a4f344d5d6c4c59a2c5b3e59 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Thu, 20 Aug 2020 13:35:47 -0400 Subject: Updated documentation with more explicit discussions on testing Added unit test to verify command name validation updates. --- tests/test_parsing.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index c2c242fe..62982ab5 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -836,7 +836,15 @@ def test_statement_is_immutable(): statement.raw = 'baz' -def test_is_valid_command_invalid(parser): +def test_is_valid_command_invalid(mocker, parser): + # Non-string command + valid, errmsg = parser.is_valid_command(5) + assert not valid and 'must be a string' in errmsg + + mock = mocker.MagicMock() + valid, errmsg = parser.is_valid_command(mock) + assert not valid and 'must be a string' in errmsg + # Empty command valid, errmsg = parser.is_valid_command('') assert not valid and 'cannot be an empty string' in errmsg @@ -871,6 +879,11 @@ def test_is_valid_command_valid(parser): assert valid assert not errmsg + # Subcommands can start with shortcut + valid, errmsg = parser.is_valid_command('!subcmd', is_subcommand=True) + assert valid + assert not errmsg + def test_macro_normal_arg_pattern(): # This pattern matches digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side -- cgit v1.2.1