+
    Yig              
          R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^RIH	t	H
t
HtHtHt ^RIHtHtHt ^RIHtHt ^RIHt ^RIHtHt ^R	IHtHtHtHtHtHtHtH t H!t!H"t"H#t# ]$! ]! ]%4      PL                  R
,          4      t']! 4       t(]! 4       t)]! 4       t*]! 4       t+]! 4       t,]! 4       t-RR/t.]P^                  R 4       t0]Pb                  Pd                  R 4       t3]Pb                  Pd                  R 4       t4]Pb                  Pd                  R 4       t5R t6]Pb                  Pd                  ]Pb                  Po                  R])]Pp                  ! ]*]Pb                  Pr                  R7      ]+]-.. R8OR7      R 4       4       t:]Pb                  Pd                  ]Pb                  Po                  R])]Pp                  ! ]*]Pb                  Pr                  R7      ]+]-.. R8OR7      R 4       4       t; ! R R4      t<]Pb                  Pd                  R 4       t= ! R R4      t>]Pb                  Pd                  R 4       t?]Pb                  Pd                  R 4       t@]Pb                  Pd                  R 4       tA]Pb                  Pd                  R 4       tBR  tCR! tDR" tE]Pb                  Pd                  R# 4       tFR$ tGR% tHR& tIR' tJR( tKR) tLR* tM]Pb                  Pd                  R+ 4       tNR, tOR- tP]Pb                  Pd                  R. 4       tQR/ tRR0 tSR1 tT]Pb                  Pd                  ]Pb                  Po                  R2RR3.4      R4 4       4       tU]Pb                  Pd                  ]Pb                  Po                  R]Pp                  ! ]*]Pb                  Pr                  R7      ]+]-.. R9OR7      R5 4       4       tV]Pb                  Pd                  R6 4       tWR7 tXR# ):z+
Test the core class and factory function.
N)Path)TemporaryDirectory)createPoochretrievedownload_actionstream_download)
get_loggertemporary_fileos_cache)	file_hashhash_matches)core)HTTPDownloaderFTPDownloader)pooch_test_urldata_over_ftppooch_test_figshare_urlpooch_test_zenodo_url pooch_test_zenodo_with_slash_urlpooch_test_dataverse_urlpooch_test_registrycheck_tiny_datacheck_large_datacapture_logmirror_directorydatatiny-data.txt@098h0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2dc                "    \        \        V 4      # )z
Mirror the test data folder on a temporary directory. Needed to avoid
permission errors when pooch is installed on a non-writable path.
)r   DATA_DIR)tmp_paths   &7/usr/lib/python3/dist-packages/pooch/tests/test_core.pydata_dir_mirrorr#   5   s     Hh//    c            
     t   \        4       ;_uu_ 4       p Rp\        V,           p\        4       ;_uu_ 4       p\        VRV R7      pVP	                  4       pVP                  4       ^ ,          R8X  g   Q hRV9   g   Q h\        V,          V9   g   Q h RRR4       VX\        V4      ) R 8X  g   Q h\        V4       \        V4      \        V,          8X  g   Q h\        4       ;_uu_ 4       p\        VRV R7      pVP	                  4       R8X  g   Q h RRR4       \        4       ;_uu_ 4       p\        V\        V,          V R7      pVP	                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     Ly; i  + '       g   i     L@; i  + '       g   i     R# ; i)z'Try downloading some data with retriever   N)
known_hashpathDownloadingSHA256 hash of downloaded file: )
r   BASEURLr   r   getvaluesplitREGISTRYlenr   r   local_store	data_fileurllog_filefnamelogss         r"   test_retriever7   >   sX    
		#		!]]hSTDE$$&D::<?m3334<<<I&$...  E3y>/"344448I#6666]]hSTDE$$&",,,  ]]hSXi-@{SE$$&",,, % 
	 ] ] ]% 
		sT   "F&AE-	AF&(&F 	F&)1F	F&-E=8F& FF&F#F&&F7	c                 >   \        4       ;_uu_ 4       p Rp\        V,           p\        4       ;_uu_ 4       p\        VRWR7      pVP	                  4       pVP                  4       ^ ,          R8X  g   Q hRV9   g   Q h\        V,          V9   g   Q h RRR4       V\        P                  P                  X4      ^,          8X  g   Q h\        V4       \        V4      \        V,          8X  g   Q h RRR4       R#   + '       g   i     Lp; i  + '       g   i     R# ; i)zATry downloading some data with retrieve and setting the file namer   N)r&   r'   r5   r(   r)   )r   r+   r   r   r,   r-   r.   osr'   r   r   r0   s         r"   test_retrieve_fnamer:   X   s     
		#		!]]hSTUE$$&D::<?m3334<<<I&$...  BGGMM%033338I#6666 
	 ]	 
		s$   "DAC8	AD8DDD	c                    Rp \         V ,           p\        R4      V ,          p \        4       ;_uu_ 4       p\        VRV R7      pVP	                  4       pVP                  4       ^ ,          R8X  g   Q h\        \        R4      P                  4       4      V9   g   Q hRV9   g   Q h\        V ,          V9   g   Q h RRR4       X\        VP                  4       4      8X  g   Q h\        V4       \        V4      \        V ,          8X  g   Q h \        P                  P                  \        V4      4      '       d"   \        P                  ! \        V4      4       R# R#   + '       g   i     L; i  \        P                  P                  \        T4      4      '       d!   \        P                  ! \        T4      4       i i ; i)zETry downloading some data with retrieve to the default cache locationr   poochN)r&   r5   r(   zSHA256 hash of downloaded file)r+   r   r   r   r,   r-   strresolver.   r   r   r9   r'   existsremove)r2   r3   expected_locationr4   r5   r6   s         r"   test_retrieve_default_pathrB   k   sV     I
I
C )I5.]]hSTCE$$&D::<?m333x(0023t;;;3t;;;I&$...  -55788888I#666677>>#/011IIc+,- 2 ] 77>>#/011IIc+,- 2s%   E. BE9AE. E+	&E. .AF>c                    \        V R\        R7      p\        V R,          4      pVP                  R4      pW#8X  g   Q h\	        V4       R# )zASetup a pooch that already has the local data and test the fetch.some bogus URLr'   base_urlregistryr   N)r   r.   r=   fetchr   )r#   puptruer5   s   &   r"   test_pooch_localrK      s@    
_/?(
SC01DIIo&E==Er$   r3   )marks)idsc           	        \        4       ;_uu_ 4       p\        V4      pRV R,           /p\        VR\        VR7      p\	        4       ;_uu_ 4       pVP                  R4      pVP                  4       pVP                  4       ^ ,          R8X  g   Q hVP                  4       R,          RV R28X  g   Q h RRR4       \        X4       \	        4       ;_uu_ 4       pVP                  R4      pVP                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     Li; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z:Have pooch download the file from URL that is not base_urlr   r*   r'   rF   rG   urlsr(   ''.N)	r   r   r   r.   r   rH   r,   r-   r   )r3   r1   r'   rP   rI   r4   r5   r6   s   &       r"   test_pooch_custom_urlrT      s     
		K !67XDI]]hIIo.E$$&D::<?m333::<#4&|333	 
 	]]hIIo.E$$&",,,  
	 ] ] 
		s<   <D9A"D	2%D9)D&	D9D#D9&D61D99E
	c           	        \        4       ;_uu_ 4       p\        V4      p\        VR,          4      p\        W \        R7      p\        4       ;_uu_ 4       pVP                  R4      pVP                  4       pVP                  4       ^ ,          R8X  g   Q hVP                  4       R,          RV R28X  g   Q h RRR4       VX8X  g   Q h\        V4       \        V4      \        R,          8X  g   Q h\        4       ;_uu_ 4       pVP                  R4      pVP                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z:Setup a pooch that has no local data and needs to downloadr   rE   r(   rQ   rR   Nr*   rS   )r   r   r=   r   r.   r   rH   r,   r-   r   r   )r3   r1   r'   	true_pathrI   r4   r5   r6   s   &       r"   test_pooch_downloadrW      s    
		K ./	h?]]hIIo.E$$&D::<?m333::<#4&|333	  E!!!8O#<<<<]]hIIo.E$$&",,, ! 
	 ] ]! 
		s>   AE$A"D>	7AE$)E	,E$>E	E$E!E$$E5	c                   0   a  ] tR t^t o RtR tR tRtV tR# )FakeHashMatchesz8Create a fake version of hash_matches that fails n timesc                     Wn         ^ V n        R# )    N)	nfailuresfailed)selfr\   s   &&r"   __init__FakeHashMatches.__init__   s    "r$   c                    V P                   V P                  8  d.   V ;P                   ^,          un         \        V^ ,          R3/ VB # \        V/ VB # )z#Fail n times before finally passingbla)r]   r\   r   )r^   argskwargss   &*,r"   r   FakeHashMatches.hash_matches   sF    ;;'KK1KQ9&99T,V,,r$   )r]   r\   N)	__name__
__module____qualname____firstlineno____doc__r_   r   __static_attributes____classdictcell____classdict__s   @r"   rY   rY      s     >- -r$   rY   c                    \        4       ;_uu_ 4       pV P                  \        R\        ^4      P                  4       \        V4      p\        V\        \        R7      p\        P                  ! \        4      ;_uu_ 4       p\        4       ;_uu_ 4       pVP                  R4       RRR4       RRR4       R\        X4      9   g   Q hXP                  4       P!                  4       P#                  R4      p\%        V4      ^8X  g   Q hV^ ,          P'                  R4      '       g   Q hV^ ,          P)                  RV R	24      '       g   Q h RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)
z2Check that retrying the download is off by defaultr   rE   r   Ndoes not match the known hash
r(   rQ   rR   )r   setattrr   rY   r   r   r   r+   r.   pytestraises
ValueErrorr   rH   r=   r,   stripr-   r/   
startswithendswithmonkeypatchr1   r'   rI   errorr4   r6   s   &      r"   (test_pooch_download_retry_off_by_defaultr|      s    
		D./!2D2Q2QRK (C]]:&&%(		/*  ' /#e*<<<  "((*0064yA~~Aw!!-0000Aw!D6---- 
	  '& 
		sI   A.E<E)	E&E)	.A6E<%#E<	E<E&!E)	)E94E<<F	c                   0   a  ] tR t^t o RtR tR tRtV tR# )	FakeSleepz<Create a fake version of sleep that logs the specified timesc                    . V n         R # )Ntimes)r^   s   &r"   r_   FakeSleep.__init__   s	    
r$   c                <    V P                   P                  V4       R# )z Store the time and doesn't sleepN)r   append)r^   secss   &&r"   sleepFakeSleep.sleep   s    

$r$   r   N)	rf   rg   rh   ri   rj   r_   r   rk   rl   rm   s   @r"   r~   r~      s     B   r$   r~   c                F   \        4       ;_uu_ 4       pV P                  \        R\        ^4      P                  4       \        4       pV P                  \        P                  RVP                  4       \        V4      p\        VR,          4      p^p\        V\        \        VR7      p\        4       ;_uu_ 4       pVP                  R4      pVP                  4       P!                  4       P#                  R4      p	\%        V	4      ^V,           8X  g   Q hV	^ ,          P'                  R4      '       g   Q hV	^ ,          P)                  RV R24      '       g   Q h\+        \-        V^ R4      V	R	,          4       F)  w  rR
V9   g   Q hV
^8  d   RMRpRV
 RV R2V9   d   K)  Q h	  VP.                  . RO8X  g   Q h RRR4       VX8X  g   Q h\1        V4       \3        V4      \        R,          8X  g   Q h RRR4       R#   + '       g   i     LL; i  + '       g   i     R# ; i)z?Check that retrying the download works if the hash is differentr   r   r   r'   rF   rG   retry_if_failedrq   r(   rQ   rR   :   NNFailed to downloadsr*   zdownload again z
 more time.NrS   )r                        	   
   r   )r   rr   r   rY   r   r~   timer   r   r=   r   r+   r.   r   rH   r,   rv   r-   r/   rw   rx   zipranger   r   r   )rz   r1   	fakesleepr'   rV   retriesrI   r4   r5   r6   ilineplurals   &            r"   test_pooch_download_retryr      s    
		D./"2E2R2RSK	DIIw	@K ./	(G
 ]]hIIo.E$$&,,.44T:Dt9G+++7%%m44447##avRL1111uWa4d2h?+t333 !A2(:fXQ?4GGG @
 ??&IIII  E!!!8O#<<<<7 
	 ] 
		s8   B(H;A5G<	1#G<	AG<	G<	89H<HHH 	c                b   \        4       ;_uu_ 4       pV P                  \        R\        ^4      P                  4       \        V4      p\        V\        \        ^R7      p\        P                  ! \        4      ;_uu_ 4       p\        4       ;_uu_ 4       pVP                  R4       RRR4       RRR4       XP                  4       P                  4       P!                  R4      p\#        V4      ^8X  g   Q hV^ ,          P%                  R4      '       g   Q hV^ ,          P'                  RV R24      '       g   Q hR	V^,          9   g   Q hR
V^,          9   g   Q hR\)        X4      9   g   Q h RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)zFCheck that retrying the download fails after the set amount of retriesr   r   r   Nrq   r(   rQ   rR   r   zdownload again 1 more time.rp   )r   rr   r   rY   r   r   r   r+   r.   rs   rt   ru   r   rH   r,   rv   r-   r/   rw   rx   r=   ry   s   &      r"   *test_pooch_download_retry_fails_eventuallyr     sD    
		D./!2D2Q2QRK (TUV]]:&&%(		/*  '   "((*0064yA~~Aw!!-0000Aw!D6----#tAw...,Q777.#e*<<<! 
	  '& 
		sI   A/FF
	E7'F
	/A$F#F84F7FF
	
FFF.	c            	        \        4       ;_uu_ 4       p \        V 4      pR\        R,           /p\        VR\        VR7      p\        R4      ;_uu_ 4       pVP                  R4      pVP                  4       R8X  g   Q h RRR4       \        X4       RRR4       R#   + '       g   i     L%; i  + '       g   i     R# ; i)zHSetup a pooch and check that no logging happens when the level is raisedr   r*   rO   CRITICALN)	r   r   r+   r   r.   r   rH   r,   r   )r1   r'   rP   rI   r4   r5   s         r"   test_pooch_logging_levelr   3  s     
		K ?!:;XDI$$IIo.E$$&",,, % 	 
	 %$ 
		s$   AB.)B	>B.B+&B..B?	c            	        \        4       ;_uu_ 4       p \        V 4      p\        VR,          4      p\        VRRR7      ;_uu_ 4       pVP	                  R4       RRR4       \        V\        \        R7      p\        4       ;_uu_ 4       pVP                  R4      pVP                  4       pVP                  4       ^ ,          R8X  g   Q hVP                  4       R,          R	V R
28X  g   Q h RRR4       VX8X  g   Q h\        V4       \        V4      \        R,          8X  g   Q h\        4       ;_uu_ 4       pVP                  R4      pVP                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     EL#; i  + '       g   i     L; i  + '       g   i     LA; i  + '       g   i     R# ; i)zFSetup a pooch that already has the local data but the file is outdatedr   wutf-8encodingdifferent dataNrE   UpdatingrQ   rR   r*   rS   )r   r   r=   openwriter   r+   r.   r   rH   r,   r-   r   r   )r1   r'   rV   finrI   r4   r5   r6   s           r"   test_pooch_updater   B  sS    
		K  ./	)S733sII&' 4 (C]]hIIo.E$$&D::<?j000::<#4&|333	  E!!!8O#<<<<]]hIIo.E$$&",,, ) 
	
 433
 ] ]) 
		sU   4F-E3	0F-	A"F	,AF-7)F	!F-3F>	F-FF-F*%F--F>	c            	        \        4       ;_uu_ 4       p \        V 4      p\        VR,          4      p\        VRRR7      ;_uu_ 4       pVP	                  R4       RRR4       \        V\        \        RR7      p\        P                  ! \        4      ;_uu_ 4        VP                  R4       RRR4       RRR4       R#   + '       g   i     Lm; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z$Test that disallowing updates works.r   r   r   r   r   NFr'   rF   rG   allow_updates)r   r   r=   r   r   r   r+   r.   rs   rt   ru   rH   )r1   r'   rV   r   rI   s        r"   test_pooch_update_disallowedr   ^  s    			K  ./	)S733sII&' 4 	
 ]]:&&IIo& ' 
	
 43 '& 
		s<   4C$B>	AC$C	,C$>C	C$C!C$$C5	c            	        Rp  R\         P                  V &   \        4       ;_uu_ 4       p\        V4      p\	        VR,          4      p\        VRRR7      ;_uu_ 4       pVP                  R4       RRR4       \        V\        \        V R	7      p\        P                  ! \        4      ;_uu_ 4        VP                  R4       RRR4       RRR4       \         P                  P                  V 4       R#   + '       g   i     L; i  + '       g   i     LL; i  + '       g   i     LW; i  \         P                  P                  T 4       i ; i)
zDTest that disallowing updates works through an environment variable.MYPROJECT_DISALLOW_UPDATESFalser   r   r   r   r   Nr   )r9   environr   r   r=   r   r   r   r+   r.   rs   rt   ru   rH   pop)variable_namer1   r'   rV   r   rI   s         r"   (test_pooch_update_disallowed_environmentr   r  s    0M&$+

=!!![$D D?23Iiw773		*+ 8  !+	C z**		/* + "" 	

}% 87 +* "!" 	

}%sS   %D, 4DC3	/AD0D	D
D, 3D>DDDD)	$D, ,!Ec                 b    Rp \        V R\        R7      pVP                  V R,           8X  g   Q hR# )zJ
Test if pooch.create appends a trailing slash to the base url if missing
zhttps://mybase.urlN)rF   rG   r'   /)r   r    rF   )rF   rI   s     r"   ,test_pooch_create_base_url_no_trailing_slashr     s-     $H
(T
AC<<8c>)))r$   c                   \        4       ;_uu_ 4       p\        P                  P                  V4      p\	        V\
        \        R7      p\        4       ;_uu_ 4       p\        P                  ! \        4      ;_uu_ 4       pVP                  R4       RRR4       R\        XP                  4      9   g   Q hVP                  4       pVP                  4       ^ ,          R8X  g   Q hVP                  4       R	,          RV R28X  g   Q h RRR4       RRR4       \	        V \
        \        R7      p\        4       ;_uu_ 4       p\        P                  ! \        4      ;_uu_ 4       pVP                  R4       RRR4       R\        XP                  4      9   g   Q hVP                  4       pVP                  4       ^ ,          R8X  g   Q hVP                  4       R	,          RV  R28X  g   Q h RRR4       R#   + '       g   i     ELj; i  + '       g   i     EL	; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)
z>Raise an exception if the file hash doesn't match the registryrE   r   Nz(tiny-data.txt)r(   rQ   rR   r   rS   )r   r9   r'   abspathr   r+   REGISTRY_CORRUPTEDr   rs   rt   ru   rH   r=   valuer,   r-   )r#   r1   r'   rI   r4   r{   r6   s   &      r"   test_pooch_corruptedr     s    
		ww{+:LM]]hz**e		/* +$EKK(8888$$&D::<?m333::<#4&|333  
 _wAS
TC	(]]:&&%IIo& ' C$4444  "zz|A*,,,zz|BQ&7r#:::: 
 +** ]] 
		 '& 
sb   AH#H	>G1A4H	H=#I  H-	2A4I 1H<	H	H	HH*	-H=8I  I	c                     \        RR\        R7      p \        P                  ! \        4      ;_uu_ 4        V P                  R4       RRR4       R#   + '       g   i     R# ; i)z=Should raise an exception if the file is not in the registry.zit shouldn't matterzthis shouldn't eitherrE   zthis-file-does-not-exit.csvN)r   r.   rs   rt   ru   rH   rI   s    r"   test_pooch_file_not_in_registryr     sA    
"-DxC 
z	"	"		/0 
#	"	"	"s   AA"	c                 ,   \        RRR7      p V P                  \        P                  P	                  \
        R4      4       V P                  \        8X  g   Q hV P                  P                  4       \        \        4      P                  4       8X  g   Q hR# )z,Loading the registry from a file should workr*   r'   rF   registry.txtNr   load_registryr9   r'   joinr    rG   r.   registry_filessortlistr   s    r"   test_pooch_load_registryr     sg    
R"
%Cbggll8^<=<<8###""$X(;(;(====r$   c                 ,   \        RRR7      p V P                  \        P                  P	                  \
        R4      4       V P                  \        8X  g   Q hV P                  P                  4       \        \        4      P                  4       8X  g   Q hR# )z8Loading the registry from a file and strip line commentsr*   r   zregistry_comments.txtNr   r   s    r"   !test_pooch_load_registry_commentsr     sh    
R"
%Cbggll8-DEF<<8###""$X(;(;(====r$   c                    \         P                  P                  \        R4      p \	        RRR7      p\        V R4      ;_uu_ 4       pVP                  V4       RRR4       VP                  \        8X  g   Q hVP                  P                  4       \        \        4      P                  4       8X  g   Q h\	        RRR7      p\        V RRR7      ;_uu_ 4       pVP                  V4       RRR4       VP                  \        8X  g   Q hVP                  P                  4       \        \        4      P                  4       8X  g   Q hR#   + '       g   i     L; i  + '       g   i     Lx; i)	z'Loading the registry from a file objectr   r*   r   rbNrr   r   )r9   r'   r   r    r   r   r   rG   r.   r   r   r   )r'   rI   r   s      r"    test_pooch_load_registry_fileobjr     s   77<<.1D R"
%C	dD		S# 
<<8###""$X(;(;(==== R"
%C	dC'	*	*c# 
+<<8###""$X(;(;(==== 
	 
+	*s   EEE	E(	c                     \        RRR7      p V P                  \        P                  P	                  \
        R4      4       V P                  \        8X  g   Q hV P                  RR/8X  g   Q hR# )z8Load the registry from a file with a custom URL insertedr*   r   zregistry-custom-url.txtr   zhttps://some-site/tiny-data.txtN)	r   r   r9   r'   r   r    rG   r.   rP   r   s    r"   #test_pooch_load_registry_custom_urlr     sV    
R"
%Cbggll8-FGH<<8###88)JKKKKr$   c                    \        RR/ R7      p \        P                  ! \        4      ;_uu_ 4        V P	                  \
        P                  P                  \        R4      4       RRR4       R#   + '       g   i     R# ; i)z?Should raise an exception when a line doesn't have two elementsr*   rE   zregistry-invalid.txtN)	r   rs   rt   IOErrorr   r9   r'   r   r    r   s    r"   %test_pooch_load_registry_invalid_liner     sL    
R"r
2C	w		"'',,x1GHI 
 			s   4A//B 	c                     \        RRR7      p V P                  \        P                  P	                  \
        R4      4       RV P                  9   g   Q hRV P                  9   g   Q hR# )zCShould check that spaces in filenames are allowed in registry filesr*   r   zregistry-spaces.txtzfile with spaces.txtzother with spaces.txtN)r   r   r9   r'   r   r    rG   r   s    r"   $test_pooch_load_registry_with_spacesr     sP    
R"
%Cbggll8-BCD!S\\111"cll222r$   c                 p   \        \        \        \        R7      p V P	                  R4      '       g   Q h\        \        \        R,           \        R7      p V P	                  R4      '       d   Q hRR/pVP                  \        4       \        \        \        VR7      p V P	                  R4      '       d   Q hR# )FShould correctly check availability of existing and non existing filesrE   r   z
wrong-url/znot-a-real-data-file.txtnotarealhashN)r   r    r+   r.   is_availableupdate)rI   rG   s     r"   test_check_availabilityr     s     X(
CCO,,,,
X,(>
RC0000*N;HOOH
X(
CC :;;;;;r$   c           
     N   \        V R4      ;_uu_ 4       p\        \        VP                  RR4      RRRR/R7      p\	        V P
                  R7      pVP                  RVR7      '       g   Q hVP                  RVR7      '       d   Q h R	R	R	4       R	#   + '       g   i     R	# ; i)
r   r   r*   @baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2dzdoesnot_exist.zipjdjdjdjdflldrE   )port
downloaderN)r   r   r    replacer   server_portr   )	ftpserverr3   rI   r   s   &   r"   test_check_availability_on_ftpr      s    	y/	2	2c[["5!c#^
 #	(=(=>
JGGGG##$7J#OOOOO 
3	2	2	2s   A0BBB$	c                     R p \        \        \        \        R7      pRp\        P
                  ! \        VR7      ;_uu_ 4        VP                  RV R7       RRR4       R#   + '       g   i     R# ; i)z@Should raise an exception if the downloader doesn't support thisc                    R# )z,A downloader that doesn't support check_onlyN )r3   outputr<   s   &&&r"   r   >test_check_availability_invalid_downloader.<locals>.downloader  s    r$   rE   z%does not support availability checks.)matchr   r   N)r   r    r+   r.   rs   rt   NotImplementedErrorr   )r   rI   msgs      r"   *test_check_availability_invalid_downloaderr     sP     X(
CC
1C	*#	6	6Z@ 
7	6	6	6s   A""A3	c           	        R p\        4       ;_uu_ 4       p\        V4      p\        V\        \        R7      p\        4       ;_uu_ 4       pVP                  RVR7      pVP                  4       pVP                  4       p\        V4      ^8X  g   Q hV^ ,          P                  4       ^ ,          R8X  g   Q hV^,          R8X  g   Q h RRR4       V P                  4       P                  '       d   Q h\        X4       \        4       ;_uu_ 4       pVP                  R4      pVP                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z%Setup a downloader function for fetchc                Z    \        4       P                  R4       \        4       ! WV4       R# )z2Download through HTTP and warn that we're doing itdownloader executedN)r	   infor   )r3   output_filerI   s   &&&r"   download,test_fetch_with_downloader.<locals>.download#  s     /03/r$   rE   zlarge-data.txtr   r(   r   Nr*   )r   r   r   r+   r.   r   rH   r,   
splitlinesr/   r-   
readouterrerrr   )	capsysr   r1   r'   rI   r4   r5   r6   liness	   &        r"   test_fetch_with_downloaderr    s%   0
 
		K (C]]hII.8IDE$$&DOO%Eu:?"?8>>#A&-77784444  $$&*****]]hII./E$$&",,, # 
	
 ] ]# 
		sB   4E/
A;E		'E/.E/)E	7E/	EE/E,'E//F 	c                   \        V \        RR/R7      p\        P                  ! \        4      ;_uu_ 4       pVP                  R4       RRR4       R\        XP                  4      9   g   Q hR#   + '       g   i     L.; i)z!Test an invalid hashing algorithmr   z	blah:1234rE   Nz'blah')r   r+   rs   rt   ru   rH   r=   r   )r#   rI   excs   &  r"   test_invalid_hash_algr  >  s]    
w/;9WC 
z	"	"c		/" 
# s399~%%% 
#	"s   A//A?	c                   \        V R,          4      p\        V4       \        VR4      ;_uu_ 4       pVP                  4       pRRR4       R Fq  p\        P
                  ! V4      pVP                  X4       RV RVP                  4        2/p\        V RVR7      pWP                  R4      8X  g   Q h\        V4       Ks  	  R#   + '       g   i     L; i)z2Test different hashing algorithms using local datar   r   N:rD   rE   )sha512md5)
r=   r   r   readhashlibnewr   	hexdigestr   rH   )r#   r5   r   r   alghasherrG   rI   s   &       r"   #test_alternative_hashing_algorithmsr  I  s    /12EE	eT		cxxz 
 S!d#uAf.>.>.@-A%BC3ChW		/2222 ! 
	s   CC	c            	     R   \        \        R4      RR7      w  rV R8X  g   Q hVR8X  g   Q h\        4       ;_uu_ 4       p\        \        V4      RR7      w  rRRR4       V R8X  g   Q hVR8X  g   Q h\        4       ;_uu_ 4       p\        VR	R
R7      ;_uu_ 4       pVP	                  R4       RRR4       \        \        V4      \        V4      R7      w  rRRR4       V R8X  g   Q hVR8X  g   Q hR#   + '       g   i     L; i  + '       g   i     L`; i  + '       g   i     LJ; i)z>Test that the right action is performed based on file existingzthis_file_does_not_exist.txtN)r&   r   r(   znot the correct hashr   r   r   r   r   z	some datarH   Fetching)r   r   r
   r   r   r   )actionverbtmpr   s       r"   test_download_actionr  X  s    "+,LF Z=   			S&tCy=ST 
X:			S#sW--LL% .&tCyYs^L 
 W: 
	 .- 
	s/   C0DD	+)D0D 	DDD&	r5   zsubdir/tiny-data.txtc           
        \         R,           V ,           p\        V ,          p\        4       p\        4       ;_uu_ 4       p\	        V4      V ,          pVP                  4       '       d   Q h\        WW#RR7       VP                  4       '       g   Q h\        \        V4      4       RRR4       R#   + '       g   i     R# ; i)z9Check that downloading a file over HTTP works as expectedzstore/N)r<   )	r+   r.   r   r   r   r?   r   r   r=   )r5   r3   r&   r   r1   destinations   &     r"   test_stream_downloadr  m  s    
 H
u
$C%J!J			;'%/%%''''*M!!####K() 
			s   A%B--B>	c                   \        4       ;_uu_ 4       p\        P                  P                  V4      p\	        W R7      pVP                  4        \        VP                  4      ^8X  g   Q hRVP                  9   g   Q hRVP                  9   g   Q hVP                   F  pVP                  V4       K  	  RRR4       R#   + '       g   i     R# ; i)z;Check that the registry is correctly populated from the APIr   r   z	store.zipN)	r   r9   r'   r   r   load_registry_from_doir/   rG   rH   r3   r1   r'   rI   filenames   &    r"   test_load_registry_from_doir  }  s     
		ww{+,""$ 3<< A%%%#,,...cll*** HIIh % 
			s   B"B??C	c                    \         p \        4       ;_uu_ 4       p\        P                  P	                  V4      p\        W R7      pVP                  4        \        VP                  4      ^8X  g   Q hRVP                  9   g   Q hVP                   F  pVP                  V4       K  	  RRR4       R#   + '       g   i     R# ; i)zg
Check that the registry is correctly populated from the Zenodo API when
the filename contains a slash
r   z!santisoler/pooch-test-data-v1.zipN)
ZENODOURL_W_SLASHr   r9   r'   r   r   r  r/   rG   rH   r  s        r"   -test_load_registry_from_doi_zenodo_with_slashr"    s     C			ww{+,""$ 3<< A%%%2cllBBB HIIh % 
			s   BB22C	c                     \        R\        R7      p \        P                  ! \        4      ;_uu_ 4       pV P                  4        RRR4       R\        XP                  4      9   g   Q hR#   + '       g   i     L.; i)z(Check that non-DOI URLs produce an errorr*   r   Nzonly implemented for DOIs)r   r+   rs   rt   ru   r  r=   r   )rI   r  s     r"   !test_wrong_load_registry_from_doir$    sS     R'
*C	z	"	"c""$ 
# '#cii.888 
#	"s   A++A;	)httpsfigsharezenodo	dataverse)r&  r'  r(  )Yrj   r  r9   pathlibr   tempfiler   rs   r   r   r   r   r   r   utilsr	   r
   r   hashesr   r   r*   downloadersr   r   r   r   r   r   r   r   r   r   r   r   r   r=   __file__parentr    r.   r+   FIGSHAREURL	ZENODOURLr!  DATAVERSEURLr   fixturer#   marknetworkr7   r:   rB   rK   parametrizeparamr&  rT   rW   rY   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r"  r$  r   r$   r"   <module>r8     s    	  '  L L 8 8 ,  7    tH~$$v-. 

%'!#	46 ') W  0 0 - -2 7 7$ . .. 	[(<(<=	 	5  	-	 -( 	[(<(<=	 	5  	-	 -.- -  . .&    = =@ = =*   - -6'(&2* ; ;01>>>&LJ3 < <P$
A - -<&* ?4J"KL* M * 	\\+V[[%9%9:I|T+  
   "    (9r$   