From a4cf83e01a972645b13c86ad1206b06f4ad8288e Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 21 Dec 2015 23:15:22 +0100 Subject: [PATCH] Add tests for LIST. --- .../server_tests/test_channel_operations.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/irctest/server_tests/test_channel_operations.py b/irctest/server_tests/test_channel_operations.py index 28fb05c..9a3abee 100644 --- a/irctest/server_tests/test_channel_operations.py +++ b/irctest/server_tests/test_channel_operations.py @@ -132,3 +132,50 @@ class JoinTestCase(cases.BaseServerTestCase): '"foo" with an optional "+" or "@" prefix, but got: ' '{msg}') + def testListEmpty(self): + """ + + """ + self.connectClient('foo') + self.connectClient('bar') + self.getMessages(1) + self.sendLine(2, 'LIST') + m = self.getMessage(2) + self.assertMessageEqual(m, command='321', # RPL_LISTSTART + fail_msg='First reply to LIST is not 321 (RPL_LISTSTART), ' + 'but: {msg}') + m = self.getMessage(2) + self.assertNotEqual(m.command, '322', # RPL_LIST + 'LIST response gives (at least) one channel, whereas there ' + 'is none.') + self.assertMessageEqual(m, command='323', # RPL_LISTEND + fail_msg='Second reply to LIST is not 322 (RPL_LIST) ' + 'or 323 (RPL_LISTEND), or but: {msg}') + + def testListOne(self): + """ + + """ + self.connectClient('foo') + self.connectClient('bar') + self.sendLine(1, 'JOIN #chan') + self.getMessages(1) + self.sendLine(2, 'LIST') + m = self.getMessage(2) + self.assertMessageEqual(m, command='321', # RPL_LISTSTART + fail_msg='First reply to LIST is not 321 (RPL_LISTSTART), ' + 'but: {msg}') + m = self.getMessage(2) + self.assertNotEqual(m.command, '323', # RPL_LISTEND + 'LIST response ended (ie. 323, aka RPL_LISTEND) without ' + 'listing any channel, whereas there is one.') + self.assertMessageEqual(m, command='322', # RPL_LIST + fail_msg='Second reply to LIST is not 322 (RPL_LIST), ' + 'nor 323 (RPL_LISTEND) but: {msg}') + m = self.getMessage(2) + self.assertNotEqual(m.command, '322', # RPL_LIST + 'LIST response gives (at least) two channels, whereas there ' + 'is only one.') + self.assertMessageEqual(m, command='323', # RPL_LISTEND + fail_msg='Third reply to LIST is not 322 (RPL_LIST) ' + 'or 323 (RPL_LISTEND), or but: {msg}')