
    j	                       d dl mZ d dlZd dlmc mZ d dlZd dl	Z
d dlZd dlmZ d dlmZ d dlmZ d dlZ ee      j(                  Ze
j,                  j/                  dedz        Zg ZeZerej6                  ZeZesdd	d
 ej:                         v s ej<                  e      r ej>                  e      nd
iz  Z ejC                  e        er`dd
 ej:                         v s ej<                  e      r ej>                  e      nd
 ej>                  e      dz  Z"ejC                  e"        ejF                  ed       i z  Z$dde$iz  Z% e& ejN                  e%            dxZxZZe
j,                  jQ                  e      Z)e)ejT                  ejV                  <   ej6                  jY                  e)        G d d      Z-d Z.d Z/d Z0d Z1y)    )annotationsN)Path)SimpleNamespace)Anytransport_probeztelegram_transport_probe.pyz%(py2)spy2SPECz#%(py6)s
{%(py6)s = %(py4)s.loader
})py4py6zassert %(py9)spy9c                  F    e Zd Zej                  df	 	 	 ddZd Zd Zd Zy)FakeBotNc                .    || _         || _        g | _        y N)usernamefailurecalls)selfr   r   s      /home/cube/projects/richard/traning coach/.omo/evidence/task26/task26-continuous-lifecycle-observer-st_01a007da-v2-e788f5d5/test_telegram_transport_probe.py__init__zFakeBot.__init__   s     ! "
    c                D   K   | j                   j                  d       | S w)Nenterr   appendr   s    r   
__aenter__zFakeBot.__aenter__   s     

'"s    c                B   K   | j                   j                  d       y w)Nexitr   )r   _argss     r   	__aexit__zFakeBot.__aexit__"   s     

&!s   c                   K   | j                   j                  d       | j                  r| j                  t        | j                        S w)Nget_me)r   )r   r   r   r   r   r   s    r   r#   zFakeBot.get_me%   s8     

(#<<,,66s   A
A)r   strr   zException | None)	__name__
__module____qualname__mEXPECTED_BOTr   r   r!   r#    r   r   r   r      s/    nn$##7G#"7r   r   c                 ~   t               t        j                  t        j	                  dfd            } j
                  }g d}||k(  }|st        j                  d|fd||f      dt        j                         v st        j                        rt        j                        ndt        j                  |      t        j                  |      dz  }dd	|iz  }t        t        j                  |            d x}x}}d
dt        j                  ddddd}| |k(  }|st        j                  d|fd| |f      dt        j                         v st        j                  |       rt        j                  |       ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}y )Nsecretc                    S r   r*   _tokenbots    r   <lambda>zItest_gate_calls_only_get_me_and_returns_bound_readiness.<locals>.<lambda>.   s    sr   r   r#   r   ==z-%(py2)s
{%(py2)s = %(py0)s.calls
} == %(py5)sr0   py0r   py5assert %(py7)spy7z&task26-telegram-transport-readiness-v1READY_TELEGRAM_TRANSPORTz
Bot.get_meF)schemastatus	successormethodconsumes_updatesmutates_cursorwrites_state)z%(py0)s == %(py3)sresult)r7   py3zassert %(py5)sr8   )r   asynciorunr(   
getme_gater   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation	SUCCESSOR)	rC   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert2@py_format4r0   s	           @r   7test_gate_calls_only_get_me_and_returns_bound_readinessrX   ,   sB   
)C[[h0BCDF993339333339333333333333333933333333333:,[[! 6    6                    r   c                      t        t        d             t        j                  t        j
                  d      5  t        j                  t        j                  d fd             d d d        y # 1 sw Y   y xY w)NzBad Gateway)r   ztransport failurematchr,   c                    S r   r*   r.   s    r   r1   zPtest_gate_fails_closed_on_bad_gateway_or_other_transport_error.<locals>.<lambda>>       #r   )	r   RuntimeErrorpytestraisesr(   ProbeFailurerE   rF   rG   )r0   s   @r   >test_gate_fails_closed_on_bad_gateway_or_other_transport_errorrb   ;   sJ    
,}5
6C	q~~-@	AALL+=>? 
B	A	As   -A22A;c                     G d dt               }  |        t        j                  t        j                  d      5  t        j                  t        j                  dfdd             d d d        j                  }g d	}||k(  }|st        j                  d
|fd||f      dt        j                         v st        j                        rt        j                        ndt        j                  |      t        j                  |      dz  }dd|iz  }t        t        j                   |            d x}x}}y # 1 sw Y   xY w)Nc                      e Zd ZddZy)Ktest_gate_fails_closed_on_timeout_without_polling_or_sleep.<locals>.SlowBotc                   K   | j                   j                  d       t        j                         j	                          d {    y 7 w)Nr#   )r   r   rE   Eventwaitr   s    r   r#   zRtest_gate_fails_closed_on_timeout_without_polling_or_sleep.<locals>.SlowBot.get_meC   s0     JJh'--/&&(((s   AAA	AN)returnr   )r%   r&   r'   r#   r*   r   r   SlowBotre   B   s    	)r   rj   timeoutrZ   r,   c                    S r   r*   r.   s    r   r1   zLtest_gate_fails_closed_on_timeout_without_polling_or_sleep.<locals>.<lambda>I   r]   r   g{Gz?)rk   r2   r3   r5   r0   r6   r9   r:   )r   r_   r`   r(   ra   rE   rF   rG   r   rH   rI   rJ   rK   rL   rM   rN   rO   )rj   rQ   rR   rS   rT   rU   r0   s         @r   :test_gate_fails_closed_on_timeout_without_polling_or_sleeprm   A   s    )' )
 )C	q~~Y	7ALL+=tLLM 
8993339333339333333333333333933333333333 
8	7s   /D??Ec                    t        j                  t        j                  d      5  t	        j
                  t        j                  dd              d d d        t        j                  t        j                  d      5  t	        j
                  t        j                  dd              d d d        y # 1 sw Y   bxY w# 1 sw Y   y xY w)Nztoken unavailablerZ    c                    t               S r   r   r/   s    r   r1   zFtest_gate_rejects_empty_token_and_wrong_bot_identity.<locals>.<lambda>O   s    GIr   zidentity mismatchr,   c                    t        d      S )N	other_botrq   rr   s    r   r1   zFtest_gate_rejects_empty_token_and_wrong_bot_identity.<locals>.<lambda>Q   s	    '+:Nr   )r_   r`   r(   ra   rE   rF   rG   r*   r   r   4test_gate_rejects_empty_token_and_wrong_bot_identityru   M   sx    	q~~-@	AALL%=>? 
B	q~~-@	AALL+NOP 
B	A 
B	A	A	As   +B2>+B>2B;>C)2
__future__r   builtinsrJ   _pytest.assertion.rewrite	assertionrewriterH   rE   importlib.util	importlibsyspathlibr   typesr   typingr   r_   __file__parentHEREutilspec_from_file_locationr	   rQ   @py_assert0loader@py_assert5rK   rL   rM   @py_format3r   @py_format7_format_booloprU   @py_format10rN   rO   module_from_specr(   modulesnameexec_moduler   rX   rb   rm   ru   r*   r   r   <module>r      s-   "     
  !  H~~~--t;; t t      t   t    t                     NN##D)DII     7 7,@	4Qr   