def wsd(monkeypatch): WebSocketDispatcher.instances.clear() monkeypatch.setattr(WebSocket, 'send', Mock()) monkeypatch.setattr(WebSocket, 'closed', Mock()) monkeypatch.setattr(WebSocketDispatcher, 'is_closed', False) monkeypatch.setattr(WebSocketDispatcher, 'check_authentication', lambda cls: mock_session_data) monkeypatch.setattr(WebSocketDispatcher, 'fetch_headers', lambda cls: mock_header_data) return WebSocketDispatcher(None)
def orig_ws(monkeypatch): monkeypatch.setattr(ws4py.websocket.WebSocket, '__init__', Mock(return_value=None)) monkeypatch.setattr(WebSocketDispatcher, 'check_authentication', Mock(return_value={'username': '******'})) return WebSocketDispatcher()
def wsd(monkeypatch): monkeypatch.setattr(WebSocket, 'send', Mock()) monkeypatch.setattr(WebSocket, 'closed', Mock()) monkeypatch.setattr(WebSocketDispatcher, 'check_authentication', lambda self: 'mock_user') return WebSocketDispatcher(None)