From 462fa9162275159e87607e1ebffbafe1494de7eb Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 10 Sep 2019 19:21:56 -0700 Subject: [PATCH] Add validate-hostname tests from ircdocs/parser-tests --- test/test_irc_parsers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_irc_parsers.py b/test/test_irc_parsers.py index 7260715..c23c2d8 100644 --- a/test/test_irc_parsers.py +++ b/test/test_irc_parsers.py @@ -23,6 +23,8 @@ class MessageParserTest(unittest.TestCase): cls.USER_HOST_SPLIT_TEST_DATA = yaml.safe_load(f) with open(PARSER_DATA_PATH / 'mask-match.yaml') as f: cls.MASK_MATCH_TEST_DATA = yaml.safe_load(f) + with open(PARSER_DATA_PATH / 'validate-hostname.yaml') as f: + cls.VALIDATE_HOSTNAME_TEST_DATA = yaml.safe_load(f) def testMessageSplit(self): for testdata in self.MESSAGE_SPLIT_TEST_DATA['tests']: @@ -92,5 +94,14 @@ class MessageParserTest(unittest.TestCase): with self.subTest(): self.assertFalse(utils.match_text(mask, fail)) + def testValidateHostname(self): + for test in self.VALIDATE_HOSTNAME_TEST_DATA['tests']: + with self.subTest(): + self.assertEqual(test['valid'], IRCCommonProtocol.is_server_name(test['host']), + "Failed test for %r; should be %s" % (test['host'], test['valid'])) + + + # N.B. skipping msg-join tests because PyLink doesn't think about messages that way + if __name__ == '__main__': unittest.main()