
    si                    |   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  \(       a  SSKJr  SSKJr  SSKJr  Sr   S         SS jjr S         SS jjr        SS jrS S jr  " S S5      r!  S!     S"S jjr" " S S5      r#S#S jr$g)$z;Collection of helper functions used in conda.notices tests.    )annotationsN)chain)Path)TYPE_CHECKING   )json)get_channel_objs)get_notices_cache_file)get_channel_name_and_urls)ChannelNoticeResponse)Sequence)mock)Contextz:Here is an example message that will be displayed to usersc           
     r   U=(       d7    [         R                   R                  [         R                  R                  5      nU=(       d    U[         R                  " SS9-   nSU  Vs/ s HC  n[        [        R                  " 5       5      UUUR                  5       UR                  5       S.PME     sn0$ s  snf )N   )daysnotices)idmessagelevel
created_at
expired_at)	datetimenowtimezoneutc	timedeltastruuiduuid4	isoformat)messagesr   r   r   r   s        =lib/python3.13/site-packages/conda/testing/notices/helpers.pyget_test_noticesr$      s     Kx0044X5F5F5J5JKJFzH,>,>A,FFJ 	 $	
 $ $**,'"(224(224 $	
 	
s   &A
B4c                   ^^^^ S nUUU4S jn[        U" 5       U" 5       5      m[        U4S j[        S5       5       5      U " 5       R                  l        g)zCAdds any number of MockResponse to MagicMock object as side_effectsc               3  ,   #     [        S0 5      v   M  7f)Ni  MockResponse     r#   forever_404%add_resp_to_mock.<locals>.forever_404<   s     sB'' s   c               3  (   >#    [        TT TS9v   g 7f)N)	raise_excr'   )messages_jsonr.   status_codes   r#   one_200!add_resp_to_mock.<locals>.one_200@   s     ;KKs   c              3  :   >#    U  H  n[        T5      v   M     g 7fN)next).0_chns     r#   	<genexpr>#add_resp_to_mock.<locals>.<genexpr>D   s     *Ij499js   d   N)r   tuplerangegetside_effect)mock_sessionr0   r/   r.   r+   r1   r8   s    ```  @r#   add_resp_to_mockrA   4   s?    (L 	;=
)C%**IeCj*I%ILN"r*   c                    [        X!5       HD  u  p4U R                  U5      R                  S5       n[        R                  " X55        SSS5        MF     g! , (       d  f       MX  = f)z,Creates the cache files that we use in testswN)zipjoinpathopenr   dump)	cache_dircache_filesmessages_json_seqmessage_jsonfilefps         r#   create_notice_cache_filesrN   G   sN     ""3A%**3/2IIl' 0/ B//s   A
A$	c                    [        5       n[        R                  " UUR                  5       R                  UR                  5       R
                  U -
  4S9  g)z~
Allows for offsetting the mtime of the notices cache file. This is often
used to mock an older creation time the cache file.
)timesN)r
   osutimestatst_atimest_mtime)mtime_offset
cache_files     r#   offset_cache_file_mtimerX   R   sB    
 ()JHH )):??+<+E+E+TUr*   c                      \ rS rSrSrS rSrg)	DummyArgs^   z7Dummy object that sets all kwargs as object properties.c                \    SU l         UR                  5        H  u  p#[        XU5        M     g )NT)no_ansi_colorsitemssetattr)selfkwargskeyvals       r#   __init__DummyArgs.__init__a   s&    "HCDs# 'r*   )r]   N)__name__
__module____qualname____firstlineno____doc__rd   __static_attributes__r)   r*   r#   rZ   rZ   ^   s
    A$r*   rZ   c                    U R                   S:X  d   eX R                  ;   d   eU H.  nU(       a  X@R                  ;  d   eM  X@R                  ;   a  M.   e   g)zW
Tests a run of notices decorator where we expect to see the messages
print to stdout.
 N)errout)capturedr"   
dummy_mesgnot_inmesgs        r#   *notices_decorator_assert_message_in_stdoutrt   h   sS     <<2%%%||+++<<'''	 r*   c                  $    \ rS rSrSS jrS rSrg)r(   |   c                (    Xl         X l        X0l        g r4   )r0   	json_datar.   )r`   r0   rx   r.   s       r#   rd   MockResponse.__init__}   s    &""r*   c                R    U R                   (       a  [        S5      eU R                  $ )NError)r.   
ValueErrorrx   )r`   s    r#   r   MockResponse.json   s    >>W%%~~r*   )rx   r.   r0   NF)rf   rg   rh   ri   rd   r   rk   r)   r*   r#   r(   r(   |   s    #
r*   r(   c                N    [        [        U 5      5      n[        S U 5       5      $ )zBReturns the filenames of the cache files that will be searched forc              3  z   #    U  H1  u  p[         R                  " U[        S 5      5      R                  v   M3     g7f)rm   N)r   get_cache_keyr   name)r6   urlr   s      r#   r9   -get_notice_cache_filenames.<locals>.<genexpr>   s0      /IC 	++Cb:??/s   9;)r   r	   r<   )ctxchannel_urls_and_namess     r#   get_notice_cache_filenamesr      s-    67G7LM /  r*   )infoNN)
r"   Sequence[str]r   
str | Noner   datetime.datetime | Noner   r   returndictr~   )
r@   zmock.MagicMockr0   intr/   r   r.   boolr   None)rH   r   rI   r   rJ   zSequence[dict]r   r   )r   r   )NF)r"   r   rq   r   rr   r   )r   r   r   z
tuple[str])%rj   
__future__r   r   rQ   r   	itertoolsr   pathlibr   typingr   common.serializer   models.channelr	   notices.cacher
   notices.corer   notices.typesr   collections.abcr   unittestr   base.contextr   DEFAULT_NOTICE_MESGr$   rA   rN   rX   rZ   rt   r(   r   r)   r*   r#   <module>r      s-   B "  	      $ . 3 5 2('R 
 +/+/	 ) )	
 
6 	J JJ J 	J
 
J&((( &( 
	(	$ $ "	(( ( 	((	 	r*   