U
    ʼbJ"                     @   s   d dl Z ddlmZ ddlT ddlT ddlmZmZmZ dd Zdd	 Z	d
d Z
dd ZeeeedeiZdd Zdd Zdd Zdd Zdd Zdd ZdS )    N   )LocalProtocolError)*)ConnectionState_SWITCH_UPGRADE_SWITCH_CONNECTc               	   C   s  t  } | jttttikst| tt | jtttt	iks>tt
t | tt W 5 Q R X | jtttt	iksvt| tt | jtttt	ikst| tt | jttttikst| tt | tt | jttttikst| tt | jttttikstd S N)r   statesCLIENTIDLESERVERAssertionErrorprocess_eventRequest	SEND_BODYSEND_RESPONSEpytestraisesr   InformationalResponseResponseEndOfMessageDONEConnectionClosed
MUST_CLOSEZCLOSEDcs r   8/tmp/pip-unpacked-wheel-rko__zic/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<t
| tt | tt | jttttiksjt
d S r   )r   r   r
   r   process_keep_alive_disabledr   r	   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ks0t|   | jt t	ksJtd S r   )
r   r   r
   r   r   r	   r   r   r   r   r   r   r   r   'test_ConnectionState_keep_alive_in_DONE3   s    r!   c                  C   s  t tfD ] } dD ]}t }||  |tt |tt |jtt	t
tiksTt| |jksbt|r||t
t |jr|t|tt |r|jttt
t	ikstq|jttt
tikst|t
t |jttt
tikst|t
t |jttt
t	ikst|jrtqqd S )N)TF)r   r   r   process_client_switch_proposalr   r
   r   Datar	   r   r   r   r   Zpending_switch_proposalsr   r   r   MIGHT_SWITCH_PROTOCOLr   )Zswitch_typeZ
deny_earlyr   r   r   r   "test_ConnectionState_switch_denied>   s4    

 
 
r%   c                  C   s   t tfD ]} t }||  |tt |tt |jtt	t
tiksJt|tt |jttt
tikslt|t
t |jttt
tikst|t
t|  |  |jttt
tikstqd S r   )r   r   r   r"   r   r
   r   r#   r	   r   r   r   r   r   r$   r   _response_type_for_switchSWITCHED_PROTOCOL)Zswitch_eventr   r   r   r   -test_ConnectionState_protocol_switch_acceptedd   s6    
 
 
 
 r(   c                  C   s   d t tfD ]} t }|t  |t |tt |tt |jtt	t
tiksVt|t
t|  |  | d kr|jttt
tikstq
|jttt
tiks
tq
d S r   )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   sx   g t fg tftgt ft gtffD ]R\} }t }| D ]}|| q2|tt tt	 |t
t| W 5 Q R X 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sFt| tt | jttt
tiksht| t
t | jttt
t	ikstd S r   )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   s  t  } tt |   W 5 Q R X | tt | tt tt |   W 5 Q R X | t	t
 | t	t |   | jttt	tikst| tt |   | tt | t	t
 | t	t tt |   W 5 Q R X t  } | tt | tt | tt | t	t
 | t	t tt |   W 5 Q R X t  } | t | tt | tt | t	tt tt |   W 5 Q R X t  } | t | tt | tt | t	t
 | t	t |   | jttt	tikst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   r   test_ConnectionState_reuse   sR    

r-   c               	   C   s,   t  } tt | tt W 5 Q R X d S r   )r   r   r   r   r   r   r   r   r   r   r   test_server_request_is_illegal   s    r.   )r   Z_utilr   Z_events_stater   r   r   r   r    r!   r%   r   r   r&   r(   r*   r+   r,   r-   r.   r   r   r   r   <module>   s*   !   @