Create an AsyncWorker instance for testing.
(self)
| 217 | |
| 218 | @pytest.fixture |
| 219 | def async_worker(self): |
| 220 | """Create an AsyncWorker instance for testing.""" |
| 221 | from gunicorn.workers.base_async import AsyncWorker |
| 222 | |
| 223 | worker = AsyncWorker.__new__(AsyncWorker) |
| 224 | worker.cfg = mock.MagicMock() |
| 225 | worker.cfg.keepalive = 2 |
| 226 | worker.cfg.do_handshake_on_connect = False |
| 227 | worker.cfg.http_protocols = ["h2", "h1"] |
| 228 | worker.alive = True |
| 229 | worker.log = mock.MagicMock() |
| 230 | worker.wsgi = mock.MagicMock() |
| 231 | worker.nr = 0 |
| 232 | worker.max_requests = 1000 |
| 233 | |
| 234 | return worker |
| 235 | |
| 236 | def test_handshake_called_when_do_handshake_on_connect_false(self, async_worker): |
| 237 | """Test that do_handshake() is called when do_handshake_on_connect is False.""" |