@@ -32,13 +32,26 @@ def setUp(self):
3232 self .sendLine (2 , "USER a 0 * a" )
3333 self .sendLine (2 , "CAP REQ :server-time message-tags" )
3434 self .sendLine (2 , "CAP END" )
35- messages = self .getMessages (2 )
36- welcomes = [message for message in messages if message .command == RPL_WELCOME ]
37- self .assertEqual (len (welcomes ), 1 )
38- # should see a regburst for testnick
39- self .assertMessageMatch (welcomes [0 ], params = ["testnick" , ANYSTR ])
35+ self ._waitForWelcome (2 , "testnick" )
4036 self .joinChannel (2 , "#chan" )
4137
38+ def _waitForWelcome (self , client , nick ):
39+ """Waits for numeric 001, and returns every message after that."""
40+ while True :
41+ messages = iter (self .getMessages (client , synchronize = False ))
42+ for message in messages :
43+ if message .command == "001" :
44+ # should see a regburst for testnick
45+ self .assertMessageMatch (message , params = [nick , ANYSTR ])
46+
47+ messages_after_welcome = list (messages )
48+ messages_after_welcome += self .getMessages (client )
49+
50+ # check there is no other 001
51+ for message in messages_after_welcome :
52+ self .assertNotEqual (message .command , "001" )
53+ return messages_after_welcome
54+
4255 def _connectClient3 (self ):
4356 self .addClient ()
4457 self .sendLine (3 , "CAP LS 302" )
@@ -48,11 +61,8 @@ def _connectClient3(self):
4861 self .sendLine (3 , "USER a 0 * a" )
4962 self .sendLine (3 , "CAP REQ :server-time message-tags account-tag" )
5063 self .sendLine (3 , "CAP END" )
51- messages = self .getMessages (3 )
52- welcomes = [message for message in messages if message .command == RPL_WELCOME ]
53- self .assertEqual (len (welcomes ), 1 )
5464 # should see the *same* regburst for testnick
55- self .assertMessageMatch ( welcomes [ 0 ], params = [ "testnick" , ANYSTR ] )
65+ messages = self ._waitForWelcome ( 3 , "testnick" )
5666 joins = [message for message in messages if message .command == "JOIN" ]
5767 # we should be automatically joined to #chan
5868 self .assertMessageMatch (joins [0 ], params = ["#chan" ])
@@ -68,16 +78,15 @@ def _connectClient4(self):
6878 self .sendLine (4 , "USER a 0 * a" )
6979 self .sendLine (4 , "CAP REQ server-time" )
7080 self .sendLine (4 , "CAP END" )
71- messages = self .getMessages (4 )
72- welcomes = [message for message in messages if message .command == RPL_WELCOME ]
73- self .assertEqual (len (welcomes ), 1 )
81+ # should see the *same* regburst for testnick
82+ self ._waitForWelcome (4 , "testnick" )
7483
75- @cases .mark_specifications ("Ergo" )
84+ @cases .mark_specifications ("Ergo" , "Sable" )
7685 def testAutomaticResumption (self ):
7786 """Test logging into an account that already has a client joins the client's session"""
7887 self ._connectClient3 ()
7988
80- @cases .mark_specifications ("Ergo" )
89+ @cases .mark_specifications ("Ergo" , "Sable" )
8190 def testChannelMessageFromOther (self ):
8291 """Test that all clients attached to a session get messages sent by someone else
8392 to a channel"""
@@ -111,7 +120,7 @@ def testChannelMessageFromOther(self):
111120 self .assertNotIn ("account" , messageforfour .tags )
112121 self .assertNotIn ("msgid" , messageforfour .tags )
113122
114- @cases .mark_specifications ("Ergo" )
123+ @cases .mark_specifications ("Ergo" , "Sable" )
115124 def testChannelMessageFromSelf (self ):
116125 """Test that all clients attached to a session get messages sent by an other client
117126
@@ -149,7 +158,7 @@ def testChannelMessageFromSelf(self):
149158 self .assertNotIn ("account" , messageforfour .tags )
150159 self .assertNotIn ("msgid" , messageforfour .tags )
151160
152- @cases .mark_specifications ("Ergo" )
161+ @cases .mark_specifications ("Ergo" , "Sable" )
153162 def testDirectMessageFromOther (self ):
154163 """Test that all clients attached to a session get copies of messages sent
155164 by an other client of that session directly to an other user"""
@@ -167,7 +176,7 @@ def testDirectMessageFromOther(self):
167176 self .assertEqual (messagefortwo .params , messageforthree .params )
168177 self .assertEqual (messagefortwo .tags ["msgid" ], messageforthree .tags ["msgid" ])
169178
170- @cases .mark_specifications ("Ergo" )
179+ @cases .mark_specifications ("Ergo" , "Sable" )
171180 def testDirectMessageFromSelf (self ):
172181 """Test that all clients attached to a session get copies of messages sent
173182 by an other client of that session directly to an other user"""
@@ -187,17 +196,20 @@ def testDirectMessageFromSelf(self):
187196 messageForRecipient .tags ["msgid" ], copyForOtherSession .tags ["msgid" ]
188197 )
189198
190- @cases .mark_specifications ("Ergo" )
199+ @cases .mark_specifications ("Ergo" , "Sable" )
191200 def testQuit (self ):
192201 """Test that a single client of a session does not make the whole user quit
193202 (and is generally not visible to anyone else, not even their other sessions),
194203 until the last client quits"""
195204 self ._connectClient3 ()
196205 self ._connectClient4 ()
197206 self .sendLine (2 , "QUIT :two out" )
198- quitLines = [msg for msg in self .getMessages (2 ) if msg .command == "QUIT" ]
207+ quitLines = [
208+ msg for msg in self .getMessages (2 ) if msg .command in ("QUIT" , "ERROR" )
209+ ]
199210 self .assertEqual (len (quitLines ), 1 )
200- self .assertMessageMatch (quitLines [0 ], params = [StrRe (".*two out.*" )])
211+ if quitLines [0 ].command == "QUIT" :
212+ self .assertMessageMatch (quitLines [0 ], params = [StrRe (".*two out.*" )])
201213 # neither the observer nor the other attached session should see a quit here
202214 quitLines = [msg for msg in self .getMessages (1 ) if msg .command == "QUIT" ]
203215 self .assertEqual (quitLines , [])
@@ -218,9 +230,12 @@ def testQuit(self):
218230 self .sendLine (4 , "QUIT :four out" )
219231 self .getMessages (4 )
220232 self .sendLine (3 , "QUIT :three out" )
221- quitLines = [msg for msg in self .getMessages (3 ) if msg .command == "QUIT" ]
233+ quitLines = [
234+ msg for msg in self .getMessages (3 ) if msg .command in ("QUIT" , "ERROR" )
235+ ]
222236 self .assertEqual (len (quitLines ), 1 )
223- self .assertMessageMatch (quitLines [0 ], params = [StrRe (".*three out.*" )])
237+ if quitLines [0 ].command == "QUIT" :
238+ self .assertMessageMatch (quitLines [0 ], params = [StrRe (".*three out.*" )])
224239 # observer should see *this* quit
225240 quitLines = [msg for msg in self .getMessages (1 ) if msg .command == "QUIT" ]
226241 self .assertEqual (len (quitLines ), 1 )
0 commit comments