
    8'h                         d dl Z d dlZd dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 d Z
d Zd Ze j                  j                  d	        Zd
 Zd Z G d d      Zy)    N)ConnectionError)
registries)OrderedRegistryassert_resetc                       G d dt         j                        t        j                  fd       }  |         t	                y )Nc                       e Zd Zy)3test_set_registry_not_empty.<locals>.CustomRegistryN__name__
__module____qualname__     [/var/www/html/trade_iq/venv/lib/python3.12/site-packages/responses/tests/test_registries.pyCustomRegistryr
          r   r   c                  $   d} t        j                  t         j                  |        t        j                  t
              5 }t         j                  j                         d d d        t        j                        }d|v sJ y # 1 sw Y   %xY w)Nzhttp://fizzbuzz/foo)methodurlz7Cannot replace Registry, current registry has responses)
	responsesaddGETpytestraisesAttributeErrormock_set_registrystrvalue)r   excinfomsgr   s      r   runz(test_set_registry_not_empty.<locals>.run   sk    #Y]]4]]>* 	9gNN((8	9'-- HCOOO	9 	9s    BBr   FirstMatchRegistryr   activater   )r#   r   s    @r   test_set_registry_not_emptyr'      s=    66  P P ENr   c                       G d dt         j                        t        j                        fd       } t        j                  d        } |          |        t	                y )Nc                       e Zd Zy))test_set_registry.<locals>.CustomRegistryNr   r   r   r   r   r*      r   r   r   registryc                  ^    t        t        j                  j                                k(  sJ y Ntyper   r   get_registryr   s   r   run_with_registryz,test_set_registry.<locals>.run_with_registry    #    INN//12nDDDr   c                  x    t        t        j                  j                               t        j
                  k(  sJ y r.   r0   r   r   r1   r   r%   r   r   r   r#   ztest_set_registry.<locals>.run$   *     INN//12j6S6SSSSr   r$   )r3   r#   r   s     @r   test_set_registryr8      sd    66  0E 1E T T ENr   c                       G d dt         j                        t        j                  d        } t        j                        fd       } |          |        t	                y)z5See https://github.com/getsentry/responses/issues/563c                       e Zd Zy)2test_set_registry_reversed.<locals>.CustomRegistryNr   r   r   r   r   r;   1   r   r   r   c                  x    t        t        j                  j                               t        j
                  k(  sJ y r.   r6   r   r   r   r#   z'test_set_registry_reversed.<locals>.run4   r7   r   r+   c                  ^    t        t        j                  j                                k(  sJ y r.   r/   r2   s   r   r3   z5test_set_registry_reversed.<locals>.run_with_registry9   r4   r   Nr$   r#   r3   r   s     @r   test_set_registry_reversedr?   .   sd    66  T T 0E 1E ENr   c                     K    G d dt         j                        t        j                  d        } t        j                        fd       } |         d {     |        d {    t	                y 7 7 w)Nc                       e Zd Zy)+test_registry_async.<locals>.CustomRegistryNr   r   r   r   r   rB   D   r   r   r   c                     K   t        t        j                  j                               t        j
                  k(  sJ y wr.   r6   r   r   r   r#   z test_registry_async.<locals>.runG   s.      INN//12j6S6SSSSs   <>r+   c                  f   K   t        t        j                  j                                k(  sJ y wr.   r/   r2   s   r   r3   z.test_registry_async.<locals>.run_with_registryL   s'     INN//12nDDDs   .1r$   r>   s     @r   test_registry_asyncrE   B   s{     66  T T 0E 1E %KK

N s$   AA>A:A>*A<+A><A>c                  ,    d }  |         t                y )Nc                  @    G d dt         j                        } t        j                  d|       5 }t	        |j                               | k(  sJ t	        t        j                  j                               t         j                  k(  sJ 	 d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)Ftest_set_registry_context_manager.<locals>.run.<locals>.CustomRegistryNr   r   r   r   r   rI   W       r   r   Fassert_all_requests_are_firedr,   )r   r%   r   RequestsMockr0   r1   r   r   rspss     r   r#   z.test_set_registry_context_manager.<locals>.runV   s    	Z:: 	 ##*/.
 	X))+,>>>	3356*:W:WWWW		X 	X 	Xs   ABBr   r#   s    r   !test_set_registry_context_managerrQ   U   s    X ENr   c                  ,    d }  |         t                y )Nc                       G d dt         j                        } t        j                  d|       5 }|j	                         j                          |j                         rJ 	 d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)8test_registry_reset.<locals>.run.<locals>.CustomRegistryNr   r   r   r   r   rU   f   rJ   r   r   FrK   )r   r%   r   rM   r1   reset
registeredrN   s     r   r#   z test_registry_reset.<locals>.rune   si    	Z:: 	 ##*/.
 	)%%'((((		) 	) 	)s   1A,,A5r   rP   s    r   test_registry_resetrX   d   s    ) ENr   c                       e Zd Zd Zd Zd Zy)TestOrderedRegistryc                 f    t        j                  t              d        } |        t                y )Nr+   c                  d   t        j                  t         j                  dd       t        j                  t         j                  dd       t        j                  t         j                  dd       t        j                  t         j                  dd       t        j                  d      } | j
                  dk(  sJ t        j                  d      } | j
                  dk(  sJ t        j                  d      } | j
                  dk(  sJ t        j                  d      } | j
                  dk(  sJ y )Nhttp://twitter.com/api/1/foobari  )status  i  i  )r   r   r   requestsgetstatus_code)resps    r   r#   z6TestOrderedRegistry.test_invocation_index.<locals>.runu   s    MM1
 MM1
 MM1
 MM1 << ABD##s***<< ABD##s***<< ABD##s***<< ABD##s***r   r   r&   r   r   selfr#   s     r   test_invocation_indexz)TestOrderedRegistry.test_invocation_indext   s+    			_	5	+ 
6	+> 	r   c                 f    t        j                  t              d        } |        t                y )Nr+   c                     t        j                  t         j                  dddid       t        j                  t         j                  dddid       t        j                  t         j                  dddid	       t        j                  d      } | j
                  dk(  sJ t        j                  t              5 }t        j                  d       d d d        t        j                        }d
|v sJ y # 1 sw Y   %xY w)Nr]   r"   z	not foundr_   )jsonr^   zhttp://twitter.com/api/1/barfooi  OK   z- GET http://twitter.com/api/1/barfoo Next 'Response' in the order doesn't match due to the following reason: URL does not match)r   r   r   r`   ra   rb   r   r   r   r   r    )rc   r!   r"   s      r   r#   z/TestOrderedRegistry.test_not_match.<locals>.run   s    MM1[)	 MM1[)	 MM1T]	 << ABD##s***/ @7>?@ gmm$CV  	@ @s   ;C55C>rd   re   s     r   test_not_matchz"TestOrderedRegistry.test_not_match   s,    			_	5	 
6	@ 	r   c                 f    t        j                  t              d        } |        t                y )Nr+   c                      t        j                  t              5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nr]   )r   r   r   r`   ra   r   r   r   r#   z4TestOrderedRegistry.test_empty_registry.<locals>.run   s4    / @>?@ @ @s	   9Ard   re   s     r   test_empty_registryz'TestOrderedRegistry.test_empty_registry   s-    			_	5	@ 
6	@ 	r   N)r   r   r   rg   rm   rp   r   r   r   rZ   rZ   s   s    "H#Jr   rZ   )r   r`   requests.exceptionsr   r   r   responses.registriesr   responses.tests.test_responsesr   r'   r8   r?   markasynciorE   rQ   rX   rZ   r   r   r   <module>rv      s]      /    0 7"$(  $Q Qr   