o
    ɷ6ig!                     @   s   d dl Z ddlT ddlT ddlmZmZmZ ddl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   )*)_SWITCH_CONNECT_SWITCH_UPGRADEConnectionState)LocalProtocolErrorc                  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 s5w   Y  | jttttiksEJ | tt | jttttiksVJ | tt | jttttiksgJ | tt | tt | jttttiks~J | tt | jttttiksJ d S N)r   statesCLIENTIDLESERVERprocess_eventRequest	SEND_BODYSEND_RESPONSEpytestraisesr   InformationalResponseResponseEndOfMessageDONEConnectionClosed
MUST_CLOSECLOSEDcs r   Y/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/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s5J 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 sJ |   | jt tu s%J d S r   )	r   r   r
   r   r   r	   r   r   r   r   r   r   r   'test_ConnectionState_keep_alive_in_DONE6   s   r!   c                  C   s  t tfD ]} dD ]{}t }||  |tt |tt |jtt	t
tiks)J | |jv s0J |r=|t
t |jr=J |tt |rQ|jttt
t	iksPJ q|jttt
tiks\J |t
t |jttt
tiksmJ |t
t |jttt
t	iks~J |jrJ qqd S )N)TF)r   r   r   process_client_switch_proposalr   r
   r   Datar	   r   r   r   pending_switch_proposalsr   r   r   MIGHT_SWITCH_PROTOCOLr   )switch_type
deny_earlyr   r   r   r   "test_ConnectionState_switch_deniedB   s8   



r(   c                  C   s   t tfD ]W} t }||  |tt |tt |jtt	t
tiks%J |tt |jttt
tiks6J |t
t |jttt
tiksGJ |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_switchSWITCHED_PROTOCOL)switch_eventr   r   r   r   -test_ConnectionState_protocol_switch_acceptedn   s   
r,   c                  C   s   d t tfD ]J} t }|t  |t |tt |tt |jtt	t
tiks+J |t
t|  |  | d u rD|jttt
tiksCJ q|jttt
tiksOJ 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 ]3\} }t }| D ]}|| q|tt tt	 |t
t| W d    n1 s>w   Y  qd S r   )r   r   r   r"   r   r
   r   r   r   r   r   r   )client_switchesr-   r   client_switchr   r   r   1test_ConnectionState_inconsistent_protocol_switch   s   r1   c                  C   s   t  } | t | tt |   | tt | jtt	t
tiks#J | tt | jttt
tiks4J | t
t | jttt
t	iksEJ 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   
r2   c                  C   sb  t  } tt |   W d    n1 sw   Y  | tt | tt tt |   W d    n1 s<w   Y  | t	t
 | t	t |   | jttt	tiks\J | tt |   | tt | t	t
 | t	t tt |   W d    n1 sw   Y  t  } | tt | tt | tt | t	t
 | t	t tt |   W d    n1 sw   Y  t  } | t | tt | tt | t	tt tt |   W d    n1 sw   Y  t  } | t | tt | tt | t	t
 | t	t |   | jttt	tiks/J d S r   )r   r   r   r   start_next_cycler   r
   r   r   r   r   r	   r   r   r   r"   r   r   r   r   r   r   test_ConnectionState_reuse   s\   






r4   c                  C   sB   t  } tt | tt W d    d S 1 sw   Y  d S r   )r   r   r   r   r   r   r   r   r   r   r   test_server_request_is_illegal   s   "r5   )r   _events_stater   r   r   _utilr   r   r    r!   r(   r   r   r)   r,   r.   r1   r2   r4   r5   r   r   r   r   <module>   s&     &A