@@ -156,7 +156,6 @@ def create_connection(*args, **kwargs):
156
156
) as client :
157
157
self .assertTrue (client .create_connection_ran )
158
158
159
- @unittest .skip ("TODO - skipped to get a passing run" )
160
159
async def test_reconnect (self ):
161
160
"""Client reconnects to server."""
162
161
iterations = 0
@@ -165,16 +164,24 @@ async def test_reconnect(self):
165
164
async def process_request (connection , request ):
166
165
nonlocal iterations
167
166
iterations += 1
167
+ connection .logger .critical (f"!!!!! ITERATION { iterations } " )
168
168
# Retriable errors
169
169
if iterations == 1 :
170
170
await asyncio .sleep (3 * MS )
171
171
elif iterations == 2 :
172
172
connection .transport .close ()
173
173
elif iterations == 3 :
174
174
return connection .respond (http .HTTPStatus .SERVICE_UNAVAILABLE , "🚒" )
175
+ # Successful connection
176
+ elif iterations == 4 :
177
+ pass
178
+ elif iterations == 5 :
179
+ pass
175
180
# Fatal error
176
181
elif iterations == 6 :
177
182
return connection .respond (http .HTTPStatus .PAYMENT_REQUIRED , "💸" )
183
+ else :
184
+ self .fail ("should stop after 6 iterations" )
178
185
179
186
async with serve (* args , process_request = process_request ) as server :
180
187
with self .assertRaises (InvalidStatus ) as raised :
@@ -190,7 +197,6 @@ async def process_request(connection, request):
190
197
self .assertEqual (iterations , 6 )
191
198
self .assertEqual (successful , 2 )
192
199
193
- @unittest .skip ("TODO - skipped to get a passing run" )
194
200
async def test_reconnect_with_custom_process_exception (self ):
195
201
"""Client runs process_exception to tell if errors are retryable or fatal."""
196
202
iteration = 0
@@ -200,7 +206,10 @@ def process_request(connection, request):
200
206
iteration += 1
201
207
if iteration == 1 :
202
208
return connection .respond (http .HTTPStatus .SERVICE_UNAVAILABLE , "🚒" )
203
- return connection .respond (http .HTTPStatus .IM_A_TEAPOT , "🫖" )
209
+ elif iteration == 2 :
210
+ return connection .respond (http .HTTPStatus .IM_A_TEAPOT , "🫖" )
211
+ else :
212
+ self .fail ("should stop after 2 iterations" )
204
213
205
214
def process_exception (exc ):
206
215
if isinstance (exc , InvalidStatus ):
@@ -224,7 +233,6 @@ def process_exception(exc):
224
233
"🫖 💔 ☕️" ,
225
234
)
226
235
227
- @unittest .skip ("TODO - skipped to get a passing run" )
228
236
async def test_reconnect_with_custom_process_exception_raising_exception (self ):
229
237
"""Client supports raising an exception in process_exception."""
230
238
0 commit comments