a
    ߽g"                     @   s  d dl Z ddlmZmZmZmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddddZddd	d
ZddddZddddZeee
edeiZddddZddddZddddZ ddddZ!ddddZ"ddddZ#dS )    N   )ConnectionClosedDataEndOfMessageEventInformationalResponseRequestResponse)_SWITCH_CONNECT_SWITCH_UPGRADECLIENTCLOSEDConnectionStateDONEIDLEMIGHT_SWITCH_PROTOCOL
MUST_CLOSE	SEND_BODYSEND_RESPONSESERVERSWITCHED_PROTOCOL)LocalProtocolError)returnc                  C   s$  t  } | jttttiksJ | tt | jttttiks>J t	
t | tt W d    n1 sj0    Y  | jttttiksJ | tt | jttttiksJ | tt | jttttiksJ | tt | tt | jttttiksJ | tt | jttttiks J d S N)r   statesr   r   r   process_eventr   r   r   pytestraisesr   r   r	   r   r   r   r   r   cs r    R/var/www/html/texto_audio/venv/lib/python3.9/site-packages/h11/tests/test_state.pytest_ConnectionState   s     *r"   c                  C   sn   t  } | tt |   | tt | jtttt	iks<J | tt
 | tt | jttttiksjJ d S r   )r   r   r   r   process_keep_alive_disabledr   r   r   r   r   r	   r   r    r    r!   test_ConnectionState_keep_alive>   s    r$   c                  C   sN   t  } | tt | tt | jt tu s0J |   | jt tu sJJ d S r   )	r   r   r   r   r   r   r   r#   r   r   r    r    r!   'test_ConnectionState_keep_alive_in_DONEK   s    r%   c                  C   s  t tfD ] } dD ]}t }||  |tt |tt |jtt	t
tiksTJ | |jv sbJ |r||t
t |jr|J |tt |r|jttt
t	iksJ q|jttt
tiksJ |t
t |jttt
tiksJ |t
t |jttt
t	iksJ |jrJ qqd S )N)TF)r
   r   r   process_client_switch_proposalr   r   r   r   r   r   r   r   Zpending_switch_proposalsr	   r   r   r   r   )Zswitch_typeZ
deny_earlyr   r    r    r!   "test_ConnectionState_switch_deniedW   s4    



r'   c                  C   s   t tfD ]} t }||  |tt |tt |jtt	t
tiksJJ |tt |jttt
tikslJ |t
t |jttt
tiksJ |t
t|  |  |jttt
tiksJ qd S r   )r   r
   r   r&   r   r   r   r   r   r   r   r   r   r   r   _response_type_for_switchr   )Zswitch_eventr   r    r    r!   -test_ConnectionState_protocol_switch_accepted   s    
r)   c                  C   s   d t tfD ]} t }|t  |t |tt |tt |jtt	t
tiksVJ |t
t|  |  | d u r|jttt
tiksJ q
|jttt
tiks
J q
d S r   )r   r
   r   r&   r   r   r   r   r   r   r   r   r(   r   r   r   )server_switchr   r    r    r!   +test_ConnectionState_double_protocol_switch   s    


r+   c               	   C   s   g t fg tftgt ft gtffD ]f\} }t }| D ]}|| q2|tt tt	 |t
t| W d    q 1 s|0    Y  q d S r   )r
   r   r   r&   r   r   r   r   r   r   r   r	   )Zclient_switchesr*   r   Zclient_switchr    r    r!   1test_ConnectionState_inconsistent_protocol_switch   s    r,   c                  C   s   t  } | t | tt |   | tt | jtt	t
tiksFJ | tt | jttt
tikshJ | t
t | jttt
t	iksJ d S r   )r   r&   r   r   r   r   r#   r   r   r   r   r   r   r   r	   r   r   r    r    r!   :test_ConnectionState_keepalive_protocol_switch_interaction   s    
r-   c                  C   sh  t  } tt |   W d    n1 s.0    Y  | tt | tt tt |   W d    n1 sx0    Y  | t	t
 | t	t |   | jttt	tiksJ | tt |   | tt | t	t
 | t	t tt |   W d    n1 s0    Y  t  } | tt | tt | tt | t	t
 | t	t tt |   W d    n1 s0    Y  t  } | t | tt | tt | t	tt tt |   W d    n1 s0    Y  t  } | t | tt | tt | t	t
 | t	t |   | jttt	tiksdJ d S r   )r   r   r   r   Zstart_next_cycler   r   r   r   r   r	   r   r   r#   r   r&   r   r   r   r    r    r!   test_ConnectionState_reuse   sR    &&((
(
r.   c                  C   s@   t  } tt | tt W d    n1 s20    Y  d S r   )r   r   r   r   r   r   r   r   r    r    r!   test_server_request_is_illegal
  s    r/   )$r   Z_eventsr   r   r   r   r   r   r	   _stater
   r   r   r   r   r   r   r   r   r   r   r   r   Z_utilr   r"   r$   r%   r'   r(   r)   r+   r,   r-   r.   r/   r    r    r    r!   <module>   s"   $	< &A