B
    åCeà"  ã               @   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t‚|  tt¡ | jtttt	iks>t‚t
 t¡ |  tt¡ W d Q R X | jtttt	iksvt‚|  t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¡ | jttttiksèt‚|  tt¡ | jttttikst‚d S )N)r   Ústatesr   r   r   ÚAssertionErrorÚprocess_eventr   r   r   ÚpytestÚraisesr   r   r	   r   r   r   r   r   )Úcs© r   úh/var/www/downstreamdata.science/rtclock/rtclock-venv/lib/python3.7/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<t
‚|  tt¡ |  tt¡ | jttttiksjt
‚d S )N)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 )N)
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  xt tfD ]} x dD ]ø}tƒ }| | ¡ | tt¡ | tt¡ |jtt	t
tiks\t‚| |jksjt‚|r„| t
t¡ |jr„t‚| tt¡ |r¬|jttt
t	iksªt‚q|jttt
tiksÂt‚| t
t¡ |jttt
tiksät‚| t
t¡ |jttt
t	ikst‚|jrt‚qW qW d S )N)TF)r
   r   r   Úprocess_client_switch_proposalr   r   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   s0    

r&   c              C   sÀ   xºt tgD ]®} tƒ }| | ¡ | tt¡ | tt¡ |jtt	t
tiksLt‚| tt¡ |jttt
tiksnt‚| t
t¡ |jttt
tikst‚| t
t|  | ¡ |jttt
tiks
t‚q
W d S )N)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¨   x¢d t tgD ]”} tƒ }| t ¡ | t¡ | tt¡ | tt¡ |jtt	t
tiksXt‚| t
t|  | ¡ | d krŠ|jttt
tiks t‚q|jttt
tikst‚qW d S )N)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€   xzg t fg tftgt ft gtfgD ]V\} }tƒ }x| D ]}| |¡ q6W | tt¡ t t	¡ | t
t|¡ W d Q R X q"W d S )N)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sŠt‚d S )N)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 d Q R X |  tt¡ |  tt¡ t t¡ |  ¡  W d 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 d Q R X t ƒ } |  tt¡ |  tt¡ |  tt¡ |  t	t
¡ |  t	t¡ t t¡ |  ¡  W d Q R X t ƒ } |  t¡ |  tt¡ |  tt¡ |  t	tt¡ t t¡ |  ¡  W d Q R X t ƒ } |  t¡ |  tt¡ |  tt¡ |  t	t
¡ |  t	t¡ |  ¡  | jttt	tiksút‚d S )N)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 d Q R X d S )N)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