()
| 244 | |
| 245 | |
| 246 | def test_websocket(): |
| 247 | sio = io.StringIO() |
| 248 | d = dumper.Dumper(sio) |
| 249 | with taddons.context(d) as ctx: |
| 250 | ctx.configure(d, flow_detail=3, showhost=True) |
| 251 | f = tflow.twebsocketflow() |
| 252 | d.websocket_message(f) |
| 253 | assert "it's me" in sio.getvalue() |
| 254 | sio.truncate(0) |
| 255 | |
| 256 | d.websocket_end(f) |
| 257 | assert "WebSocket connection closed by" in sio.getvalue() |
| 258 | sio.truncate(0) |
| 259 | |
| 260 | f = tflow.twebsocketflow(err=True) |
| 261 | d.websocket_end(f) |
| 262 | assert "Error in WebSocket" in sio.getvalue() |
| 263 | assert "(reason:" not in sio.getvalue() |
| 264 | sio.truncate(0) |
| 265 | |
| 266 | f = tflow.twebsocketflow(err=True, close_reason="Some lame excuse") |
| 267 | d.websocket_end(f) |
| 268 | assert "Error in WebSocket" in sio.getvalue() |
| 269 | assert "(reason: Some lame excuse)" in sio.getvalue() |
| 270 | sio.truncate(0) |
| 271 | |
| 272 | f = tflow.twebsocketflow(close_code=4000) |
| 273 | d.websocket_end(f) |
| 274 | assert "UNKNOWN_ERROR=4000" in sio.getvalue() |
| 275 | assert "(reason:" not in sio.getvalue() |
| 276 | sio.truncate(0) |
| 277 | |
| 278 | f = tflow.twebsocketflow(close_code=4000, close_reason="I swear I had a reason") |
| 279 | d.websocket_end(f) |
| 280 | assert "UNKNOWN_ERROR=4000" in sio.getvalue() |
| 281 | assert "(reason: I swear I had a reason)" in sio.getvalue() |
| 282 | |
| 283 | |
| 284 | def test_http_connect_error(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…