o
    >h`	                     @   sn   d dl mZ zd dlmZmZmZ dZW n ey   dZY nw d dlm	Z	 d dl
mZ G dd dejZd	S )
    )unittest)create_memory_agentMemoryReactorClockResolvercreate_pumperTF)inlineCallbacks)WebSocketServerProtocolc                   @   s.   e Zd Ze Zdd Zdd Zedd ZdS )	TestAgentc                 C   s   t  | _t | _| j S N)r   pumperr   reactorstartself r   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/autobahn/twisted/test/test_tx_websocket_agent.pysetUp   s   
zTestAgent.setUpc                 C   s
   | j  S r	   )r
   stopr   r   r   r   tearDown   s   
zTestAgent.tearDownc                 #   s|    G dd dt }t| j| j|}|dt V }g   fdd}|d| |d 	 |  |jV  | dg  d S )Nc                   @   s   e Zd Zdd ZdS )z.TestAgent.test_echo_server.<locals>.EchoServerc                 S   s   |  | d S r	   )sendMessage)r   msg	is_binaryr   r   r   	onMessage      z8TestAgent.test_echo_server.<locals>.EchoServer.onMessageN)__name__
__module____qualname__r   r   r   r   r   
EchoServer   s    r   zws://localhost:1234/wsc                    s     |  d S r	   )append)r   r   messagesr   r   got%   r   z'TestAgent.test_echo_server.<locals>.gotmessages   hello)r   r   r   r
   opendictonr   	sendClose	transportloseConnection	is_closedassertEqual)r   r   agentprotor    r   r   r   test_echo_server   s   
zTestAgent.test_echo_serverN)	r   r   r   HAVE_TESTINGskipr   r   r   r,   r   r   r   r   r      s    r   N)twisted.trialr   autobahn.twisted.testingr   r   r   r-   ImportErrortwisted.internet.deferr   autobahn.twisted.websocketr   TestCaser   r   r   r   r   <module>   s    