+
    :1jw                    F   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHt ^RIHt ^RIHt ^RIHt ^R	IHt ^R
IHt ]'       d   ^ RIHt ^ RIHt ^RIHt RtRR R lltR R R lltR R lt R R lt! ! R R4      t"R!R R llt# ! R R4      t$R R lt%R# )"z;Collection of helper functions used in conda.notices tests.)annotationsN)chainrepeat)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          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
   messagesSequence[str]level
str | None
created_atzdatetime.datetime | None
expired_atreturndict )formats   "=lib/python3.14/site-packages/conda/testing/notices/helpers.py__annotate__r      s:       ) )	
 
    c                   T;'       g8    \         P                   P                  \         P                  P                  4      pT;'       g    V\         P                  ! ^R7      ,           pRV  Uu. uFG  pR\        \        P                  ! 4       4      RVRVRVP                  4       RVP                  4       /NKI  	  up/# u upi )   )daysnoticesidmessager   r   r   )	datetimenowtimezoneutc	timedeltastruuiduuid4	isoformat)r   r   r   r   r#   s   &&&& r   get_test_noticesr-      s     KKx0044X5F5F5J5JKJFFzH,>,>A,FFJ 	 $	
 $ c$**,'7j224j224 $	
 	
s   /AC c               0    V ^8  d   QhRRRRRRRRR	RR
R/# )r   mock_sessionzmock.MagicMockstatus_codeintmessages_jsonr   	raise_excboolcountr   Noner   )r   s   "r   r   r   4   sD         	
  
r   c           
         \        \        \        WVR7      V4      \        \        R/ 4      4      4      V ! 4       P                  n        R# )zCAdds any number of MockResponse to MagicMock object as side_effects)r3   i  N)r   r   MockResponsegetside_effect)r/   r0   r2   r3   r5   s   &&&&&r   add_resp_to_mockr;   4   s9     &+|K)LeT|C$%&LN"r   c               (    V ^8  d   QhRRRRRRRR/# )	r   	cache_dirr   cache_filesr   messages_json_seqzSequence[dict]r   r6   r   )r   s   "r   r   r   B   s0     ( ((( &( 
	(r   c                    \        W!4       FL  w  r4V P                  V4      P                  R4      ;_uu_ 4       p\        P                  ! W54       RRR4       KN  	  R#   + '       g   i     Kc  ; i)z,Creates the cache files that we use in testswN)zipjoinpathopenr   dump)r=   r>   r?   message_jsonfilefps   &&&   r   create_notice_cache_filesrI   B   sT     ""3A%**3//2IIl' 0/ B///s   AA/c                   V ^8  d   QhRR/# )r   r   r6   r   )r   s   "r   r   r   M   s     	 	T 	r   c                    \        4       p\        P                  ! VVP                  4       P                  VP                  4       P
                  V ,
          3R7       R# )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_mtimerT   M   sB    
 ()JHH )):??+<+E+E+TUr   c                       ] tR t^YtRtR tRtR# )	DummyArgsz7Dummy object that sets all kwargs as object properties.c                	^    R V n         VP                  4        F  w  r#\        WV4       K  	  R# )TN)no_ansi_colorsitemssetattr)selfkwargskeyvals   &,  r   __init__DummyArgs.__init__\   s&    "HCDs# 'r   )rX   N)__name__
__module____qualname____firstlineno____doc__r_   __static_attributes__r   r   r   rV   rV   Y   s
    A$r   rV   c               $    V ^8  d   QhRRRRRR/# )r   r   r   
dummy_mesgr   not_inr4   r   )r   s   "r   r   r   c   s(     ( (( ( 	(r   c                    V P                   R8X  g   Q hW P                  9   g   Q hV F1  pV'       d   W@P                  9  g   Q hK  W@P                  9   d   K1  Q h	  R# )zW
Tests a run of notices decorator where we expect to see the messages
print to stdout.
 N)errout)capturedr   rh   ri   mesgs   &&&& r   *notices_decorator_assert_message_in_stdoutrp   c   sS     <<2%%%||+++<<'''	 r   c                  &    ] tR t^wtRR ltR tRtR# )r8   c                	*    Wn         W n        W0n        R # )N)r0   	json_datar3   )r[   r0   rs   r3   s   &&&&r   r_   MockResponse.__init__x   s    &""r   c                	T    V P                   '       d   \        R 4      hV P                  # )Error)r3   
ValueErrorrs   )r[   s   &r   r   MockResponse.json}   s     >>>W%%~~r   )rs   r3   r0   N)F)ra   rb   rc   rd   r_   r   rf   r   r   r   r8   r8   w   s    #
r   r8   c                    V ^8  d   QhRRRR/# )r   ctxr   r   z
tuple[str]r   )r   s   "r   r   r      s      G 
 r   c                    \        \        V 4      4      p\        ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )zBReturns the filenames of the cache files that will be searched forc              3  z   "   T F1  w  r\         P                  ! V\        R 4      4      P                  x  K3  	  R# 5i)rk   N)r   get_cache_keyr   name).0urlr~   s   &  r   	<genexpr>-get_notice_cache_filenames.<locals>.<genexpr>   s0      /IC 	++Cb:??/s   9;)r
   r   tuple)rz   channel_urls_and_namess   & r   get_notice_cache_filenamesr      sE    67G7LM5 /5 5 /  r   )infoNN)F   )NF)&re   
__future__r   r$   rM   r*   	itertoolsr   r   pathlibr   typingr   common.serializer   models.channelr   notices.cacher	   notices.corer
   notices.typesr   collections.abcr   unittestr   base.contextr   DEFAULT_NOTICE_MESGr-   r;   rI   rT   rV   rp   r8   r   r   r   r   <module>r      ss    B "  	  #    $ . 3 5 2('R .(	$ $((	 	r   