IRCClient join timeout path.
()
| 522 | |
| 523 | |
| 524 | def test_plugin_irc_client_join() -> None: |
| 525 | """IRCClient join timeout path.""" |
| 526 | client = IRCClient( |
| 527 | host="irc.example.com", |
| 528 | nickname="nick", |
| 529 | fullname="full", |
| 530 | ) |
| 531 | client.transport = _DummyTransport() |
| 532 | |
| 533 | # join() calls monotonic frequently; use a callable so we never exhaust |
| 534 | # a finite side_effect list. |
| 535 | calls = {"n": 0} |
| 536 | |
| 537 | def _mono() -> float: |
| 538 | calls["n"] += 1 |
| 539 | # Stay below deadline long enough to exercise the loop, then exceed it. |
| 540 | return 0.0 if calls["n"] < 2000 else 1.0 |
| 541 | |
| 542 | with ( |
| 543 | mock.patch.object(client, "_flush") as m_flush, |
| 544 | mock.patch.object(client, "_handshake") as m_hs, |
| 545 | mock.patch("time.monotonic", side_effect=_mono), |
| 546 | ): |
| 547 | client.join(channel="#chan", timeout=0.01, prefix="ap", key=None) |
| 548 | assert m_flush.called |
| 549 | assert m_hs.called |
| 550 | |
| 551 | with mock.patch.object(client, "_write") as m_write: |
| 552 | client.quit(message="bye", timeout=0.1) |
| 553 | assert m_write.called |
| 554 | |
| 555 | |
| 556 | def test_plugin_irc_protocol_parse_blank_line() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…