
    Gg"                         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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#y)    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)LocalProtocolErrorc                     t               } | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t        t        t        ik(  sJ t        j                  t              5  | j                  t        t               d d d        | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t               | j                  t        t        t        t        ik(  sJ | j                  t        t                | j                  t        t"        t        t$        ik(  sJ y # 1 sw Y   FxY wN)r   statesr   r   r   process_eventr	   r   r   pytestraisesr   r   r
   r   r   r   r   r   css    I/var/www/openai/venv/lib/python3.12/site-packages/h11/tests/test_state.pytest_ConnectionStater"      sZ   		B 99vt4444VW%99FMBBBB 
)	*
) 
+99FMBBBBV2399FMBBBBVX&99FI>>>>V\*V\*99vt4444 V-.99VV<<<<# 
+	*s   G''G1c                     t               } | j                  t        t               | j	                          | j                  t        t
               | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t
               | j                  t        t        t        t        ik(  sJ y r   )r   r   r   r	   process_keep_alive_disabledr   r   r   r   r   r
   r   s    r!   test_ConnectionState_keep_aliver%   >   s    		BVW%""$V\*99V]CCCCVX&V\*99VZ@@@@    c                     t               } | j                  t        t               | j                  t        t               | j
                  t           t        u sJ | j                          | j
                  t           t        u sJ y r   )	r   r   r   r	   r   r   r   r$   r   r   s    r!   'test_ConnectionState_keep_alive_in_DONEr(   K   sf     
	BVW%V\*99V$$$""$99V
***r&   c                  ~   t         t        fD ]  } dD ]  }t               }|j                  |        |j	                  t
        t               |j	                  t
        t               |j                  t
        t        t        t        ik(  sJ | |j                  v sJ |r(|j	                  t        t               |j                  rJ |j	                  t
        t               |r&|j                  t
        t        t        t        ik(  rJ |j                  t
        t         t        t        ik(  sJ |j	                  t        t"               |j                  t
        t         t        t        ik(  sJ |j	                  t        t               |j                  t
        t        t        t        ik(  sJ |j                  sJ   y )N)TF)r   r   r   process_client_switch_proposalr   r   r	   r   r   r   r   r   pending_switch_proposalsr
   r   r   r   r   )switch_type
deny_earlyr    s      r!   "test_ConnectionState_switch_deniedr.   W   sl   '9'J "B--k:VW-VT*99FM JJJJ""="====  26666V\2yyVT69$EEEEyy1M%   
   )>?yy1M%   
   2yyVT69$EEEE6666A ( :r&   c                     t         t        fD ]8  } t               }|j                  |        |j	                  t
        t               |j	                  t
        t               |j                  t
        t        t        t        ik(  sJ |j	                  t
        t               |j                  t
        t        t        t        ik(  sJ |j	                  t        t               |j                  t
        t        t        t        ik(  sJ |j	                  t        t        |    |        |j                  t
        t         t        t         ik(  r9J  y r   )r   r   r   r*   r   r   r	   r   r   r   r   r   r   r   r   _response_type_for_switchr   )switch_eventr    s     r!   -test_ConnectionState_protocol_switch_acceptedr2      s    (/:
)),7
)
&yyVYFFFF
.yyV%:FMRRRR
!67yyV%:FMRRRR
!:<!H,WyyV%6@QRRRR ;r&   c                     d t         t        fD ]  } t               }|j                  t                |j                  t               |j	                  t
        t               |j	                  t
        t               |j                  t
        t        t        t        ik(  sJ |j	                  t        t        |    |        | &|j                  t
        t        t        t        ik(  rJ |j                  t
        t        t        t        ik(  rJ  y r   )r   r   r   r*   r   r   r	   r   r   r   r   r   r0   r   r   r   )server_switchr    s     r!   +test_ConnectionState_double_protocol_switchr5      s     A
))/:
))/:
)
.yyV%:FMRRRR
-m<m	
  99vy AAAA99):FDU VVVV Br&   c                  n   g t         fg t        ft        gt         ft         gt        ffD ]~  \  } }t               }| D ]  }|j                  |        |j	                  t
        t               t        j                  t              5  |j	                  t        t        |       d d d         y # 1 sw Y   xY wr   )r   r   r   r*   r   r   r	   r   r   r   r   r
   )client_switchesr4   r    client_switchs       r!   1test_ConnectionState_inconsistent_protocol_switchr9      s    	_	_
	O,
	O,	+& ,M--m< -
)]]-.VX}= /.+ /.s   B++B4	c                     t               } | j                  t               | j                  t        t
               | j                          | j                  t        t               | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                  t        t        t        t        ik(  sJ y r   )r   r*   r   r   r   r	   r$   r   r   r   r   r   r   r   r
   r   r   s    r!   :test_ConnectionState_keepalive_protocol_switch_interactionr;      s    		B%%o6VW%""$VT"99FMBBBB V\*99!6NNNN VX&99VY????r&   c                  *   t               } t        j                  t              5  | j	                          d d d        | j                  t        t               | j                  t        t               t        j                  t              5  | j	                          d d d        | j                  t        t               | j                  t        t               | j	                          | j                  t        t        t        t        ik(  sJ | j                  t        t               | j                          | j                  t        t               | j                  t        t               | j                  t        t               t        j                  t              5  | j	                          d d d        t               } | j                  t        t               | j                  t        t               | j                  t        t               | j                  t        t               | j                  t        t               t        j                  t              5  | j	                          d d d        t               } | j                  t                | j                  t        t               | j                  t        t               | j                  t        t"        t                t        j                  t              5  | j	                          d d d        t               } | j                  t                | j                  t        t               | j                  t        t               | j                  t        t               | j                  t        t               | j	                          | j                  t        t        t        t        ik(  sJ y # 1 sw Y   xY w# 1 sw Y   IxY w# 1 sw Y   CxY w# 1 sw Y   xY w# 1 sw Y   xY wr   )r   r   r   r   start_next_cycler   r   r	   r   r   r
   r   r   r$   r   r*   r   r   r   s    r!   test_ConnectionState_reuser>      s   		B	)	*
 
+ VW%V\*	)	*
 
+ VX&V\*99vt4444 VW%""$V\*VX&V\*	)	*
 
+
 
	BVW%V\*V-.VX&V\*	)	*
 
+
 
	B%%o6VW%V\*V2OD	)	*
 
+
 
	B%%o6VW%V\*VX&V\*99vt4444w 
+	* 
+	*" 
+	* 
+	* 
+	*s;   O
O"O/O<?P	O"O,/O9<P	Pc                      t               } t        j                  t              5  | j	                  t
        t               d d d        y # 1 sw Y   y xY wr   )r   r   r   r   r   r   r	   r   s    r!   test_server_request_is_illegalr@   
  s5     
	B	)	*
) 
+	*	*s   AA)returnN)$r   _eventsr   r   r   r   r   r	   r
   _stater   r   r   r   r   r   r   r   r   r   r   r   r   _utilr   r"   r%   r(   r.   r0   r2   r5   r9   r;   r>   r@    r&   r!   <module>rF      s          '=@
A	+"7L *X( S$W&>@$>5B*r&   