3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 12:43:09 +01:00

Add in userhost-split tests from ircdocs/parser-tests

This commit is contained in:
James Lu 2019-09-10 19:12:04 -07:00
parent 01705f8393
commit fe4bea2948

View File

@ -59,6 +59,19 @@ class MessageParserTest(unittest.TestCase):
self.assertEqual(atoms['tags'], IRCCommonProtocol.parse_message_tags(inp.split(" ")), self.assertEqual(atoms['tags'], IRCCommonProtocol.parse_message_tags(inp.split(" ")),
"Parse test failed for message tags: %r" % inp) "Parse test failed for message tags: %r" % inp)
def testUserHostSplit(self):
for test in self.USER_HOST_SPLIT_TEST_DATA['tests']:
inp = test['source']
atoms = test['atoms']
with self.subTest():
if 'nick' not in atoms or 'user' not in atoms or 'host' not in atoms:
# Trying to parse a hostmask with missing atoms is an error in split_hostmask()
with self.assertRaises(ValueError):
utils.split_hostmask(inp)
else:
expected = [atoms['nick'], atoms['user'], atoms['host']]
self.assertEqual(expected, utils.split_hostmask(inp))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()