
    X                         d Z ddlmZ ddlmZ ddlmZ ddl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mZ ddlmc mZ ddlmZ ddlmZ  G d dej.                        Z G d dej.                        Zy)z(Unit tests for gsutil wildcard_iterator.    )absolute_import)print_function)division)unicode_literalsN)wildcard_iterator)InvalidUrlError)ContainsWildcard)StorageUrlFromString)ObjectToURI)SetDummyProjectForUnitTestc                        e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )CloudWildcardIteratorTestsz%Unit tests for CloudWildcardIterator.c                    t         t        |           g d| _        g d| _        | j                         | _        d| j                  j                  dd z  | _        t        | j                        | _
        | j                  j                  | j                  j                  | j                        | _
        | j                  d| j                  z        | _        t               | _        | j                  D ]D  }| j                  | j                  |d	      }| j                  j!                  t        |             F | j                  d
| j                  z        | _        t               | _        | j                  D ]D  }| j                  | j"                  |d	      }| j$                  j!                  t        |             F | j                  d| j                  z        | _        t               | _        g d}|D ]D  }| j                  | j&                  |d	      }| j(                  j!                  t        |             F y)zFCreates 2 mock buckets, each containing 4 objects, including 1 nested.)abcdabddade$)r   r   r   nested1/nested2/xyz1nested1/nested2/xyz2znested1/nested2xyz1znested1/nfile_abcz%s_N=   z%s0)bucket_name )
bucket_uriobject_namecontentsz%s1z%s2)f.txtdouble/f.txtzdouble/zf.txtdouble/foo/f.txtzdouble/foo/zf.txtdouble/bar/f.txtzdouble/bar/zf.txt)superr   setUpimmed_child_obj_namesall_obj_namesCreateBucketbase_bucket_urir   prefix_bucket_namesuribase_uri_strreplacetest_bucket0_urisettest_bucket0_obj_uri_strsCreateObjectaddtest_bucket1_uritest_bucket1_obj_uri_strstest_bucket2_uritest_bucket2_obj_uri_strs)selfobj_nameobj_uriobject_list	__class__s       5platform/gsutil/gslib/tests/test_wildcard_iterator.pyr    z CloudWildcardIteratorTests.setUp-   s    	
$d13!9DD
  ,,.D#d&:&:&F&Fs&KKDT112D))11(($*A*ACD !--%.2.E.E;F- GD%(UD"&&!!T-B-B.6+- " /g $$((g7	 ' !--%.2.E.E;F- GD%(UD"&&!!T-B-B.6+- " /g $$((g7	 ' !--%.2.E.E;F- GD%(UD"K  !!T-B-B.6+- " /g $$((g7	      c                    t        | j                  | j                        j                  dg            }| j	                  dt        |             | j	                  t        | j                        t        |d                y)z6Tests that bucket-only URI iterates just that one URI.idbucket_fields   r   N)list_test_wildcard_iteratorr)   IterBucketsassertEquallenstrr2   resultss     r7   testNoOpObjectIteratorz1CloudWildcardIteratorTests.testNoOpObjectIteratorc   sk    $$!!	##.;dV;#DFG 	QG%S../WQZAr8   c                     t        d | j                  | j                  j                  d            j	                  d      D              }| j                  | j                  |       y)z.Tests matching all objects, based on wildcard.c              3   X   K   | ]"  }t        j                  t        |             $ y wN)sixensure_textrC   .0us     r7   	<genexpr>zDCloudWildcardIteratorTests.testMatchingAllObjects.<locals>.<genexpr>m   s&      0*/AA */s   (***Texpand_top_level_bucketsN)r*   r?   r)   clone_replace_nameIterAllrA   r+   )r2   actual_obj_uri_strss     r7   testMatchingAllObjectsz1CloudWildcardIteratorTests.testMatchingAllObjectsk   sj     0)-)E)E!!44T:*<<CG)- =D =/*/0 0 	T335HIr8   c                 ^   t        t        | j                  j                  d            t        | j                  j                  d            g      }t        d | j	                  | j                  j                  d            j                  d      D              }| j                  ||       y)z6Tests matching a subset of objects, based on wildcard.r   r   c              3   2   K   | ]  }t        |        y wrI   rC   rL   s     r7   rO   zFCloudWildcardIteratorTests.testMatchingObjectSubset.<locals>.<genexpr>y         0/1A /   ab??TrQ   Nr*   rC   r)   rS   r?   rT   rA   r2   exp_obj_uri_strsrU   s      r7   testMatchingObjectSubsetz3CloudWildcardIteratorTests.testMatchingObjectSubsets   s    D!!44V<=D!!44V<=   044!!44V<>>Eg)- ?F ?//0 0 	%':;r8   c                    t        t        | j                  j                  d            g      }t        d | j	                  | j                  j                  d            j                  d      D              }| j                  ||       y)z%Tests matching a single named object.r   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zJCloudWildcardIteratorTests.testMatchingNonWildcardedUri.<locals>.<genexpr>   rZ   r[   TrQ   Nr]   r^   s      r7   testMatchingNonWildcardedUriz7CloudWildcardIteratorTests.testMatchingNonWildcardedUri   s    	T""55f=	>?A 044!!44V<>>Eg)- ?F ?//0 0 	%':;r8   c                 P   t        d | j                  | j                  j                  d            j	                  d      D              }t        d | j                  | j                  j                  d            j	                  d      D              }| j                  ||       y)z@Tests that wildcarding w/ and w/o server prefix get same result.c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zXCloudWildcardIteratorTests.testWildcardedObjectUriWithVsWithoutPrefix.<locals>.<genexpr>   s      0/1A /r[   r   TrQ   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zXCloudWildcardIteratorTests.testWildcardedObjectUriWithVsWithoutPrefix.<locals>.<genexpr>   s      0/1A /r[   z?bcdN)r*   r?   r)   rS   rT   rA   )r2   with_prefix_uri_strsno_prefix_uri_strss      r7   *testWildcardedObjectUriWithVsWithoutPrefixzECloudWildcardIteratorTests.testWildcardedObjectUriWithVsWithoutPrefix   s      044!!44V<>>Eg)- ?F ?//0 0  044!!44V<>>Eg)- ?F ?//0 0 	)+=>r8   c           	         t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  D cg c]  }t        | j                  |       c}      }| j                  ||       | j                  dt        |             | j                  d|v        yc c}w )z'Tests wildcarding with a nested subdir.*r=   nested1/N)r*   r?   r)   rS   IsPrefixr-   root_object
url_stringr!   r&   rA   rB   
assertTrue)r2   uri_strsprefixesblrxr_   s         r7   (testWildcardedObjectUriNestedSubdirMatchzCCloudWildcardIteratorTests.testWildcardedObjectUriNestedSubdirMatch   s    uHuH++0057	S__%S^^$7 151K1KL1KAd##Q	'1KLN%x0QH&OOJ(*+ 	Ms   Dc                    t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t               }t        dg      }| j                  ||       | j                  ||       y)$Tests gs://bucket/*/subdir matching.z	*/nested1rl   N)	r*   r?   r)   rS   rm   r-   rn   ro   rA   r2   actual_uri_strsactual_prefixesrs   expected_uri_strsexpected_prefixess         r7   testWildcardPlusSubdirMatchz6CloudWildcardIteratorTests.testWildcardPlusSubdirMatch   s    eOeO++00=?	COO,CNN+? ZL)&8&8r8   c                    t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  j                  d      j                  | j                  j                  d      j                  g      }t               }| j                  ||       | j                  ||       y)z&Tests gs://bucket/*/subdir/* matching.z*/nested2/*r   r   N
r*   r?   r)   rS   rm   r-   rn   ro   urirA   rx   s         r7   !testWildcardPlusSubdirSubdirMatchz<CloudWildcardIteratorTests.testWildcardPlusSubdirSubdirMatch   s    eOeO++00?A	COO,CNN+A 001GHLL001GHLL  &8&8r8   c                     t        | j                  | j                  j                  d            j	                  d            }| j                  dt        |             y)zFTests that get back an empty iterator for non-matching wildcarded URI.z*x0TrQ   r   N)r>   r?   r)   rS   rT   rA   rB   r2   ress     r7   !testNoMatchingWildcardedObjectUriz<CloudWildcardIteratorTests.testNoMatchingWildcardedObjectUri   sW    
$$!!44U;	==DW)- >E >/0C 	QC!r8   c                     	 | j                  d      j                  d      D ]  }| j                  d        y# t        $ r7}| j	                  |j
                  j                  d      dk7         Y d}~yd}~ww xY w)z<Tests that we raise an exception for wildcarded invalid URI.zbadscheme://asdfTrQ   z$Expected InvalidUrlError not raised.zUnrecognized schemeN)r?   rT   assertFalser   rp   messagefind)r2   unused_es      r7   testWildcardedInvalidObjectUriz9CloudWildcardIteratorTests.testWildcardedInvalidObjectUri   sw    C112DEMM#' N )'?@)  C
ooaiinn%:;rABBCs   7: 	A:-A55A:c                 P   t        t        | j                        | j                  j                  z   g      }t	               5  t        d | j                  d| j                  z        j                  dg      D              }ddd       | j                  |       y# 1 sw Y   xY w)z@Tests matching a single bucket based on a wildcarded bucket URI.c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zPCloudWildcardIteratorTests.testSingleMatchWildcardedBucketUri.<locals>.<genexpr>   #       KJa a&Jr[   z%s*1r:   r;   N)	r*   r&   r.   delimr   r?   r'   r@   rA   r^   s      r7   "testSingleMatchWildcardedBucketUriz=CloudWildcardIteratorTests.testSingleMatchWildcardedBucketUri   s    	d##	$t'<'<'B'B	BCE	#	%  K//040A0A1B CCN;CG& DO DJJ K K 
& 	%':; 
&	%s   A BB%c                    t        t        | j                        | j                  j                  z   t        | j                        | j                  j                  z   t        | j
                        | j
                  j                  z   g      }t               5  t        d | j                  d| j                  z        j                  dg      D              }ddd       | j                  |       y# 1 sw Y   xY w)zCTests matching a multiple buckets based on a wildcarded bucket URI.c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zOCloudWildcardIteratorTests.testMultiMatchWildcardedBucketUri.<locals>.<genexpr>   r   r[   z%s*r:   r;   N)r*   r&   r)   r   r.   r0   r   r?   r'   r@   rA   r^   s      r7   !testMultiMatchWildcardedBucketUriz<CloudWildcardIteratorTests.testMultiMatchWildcardedBucketUri   s    T""#d&;&;&A&AAT""#d&;&;&A&AAT""#d&;&;&A&AA 
 
$	%  K//040A0A1B CCN;CG& DO DJJ K K 
& 	%':; 
&	%s   A C22C;c                 >   t        t        | j                  j                  d            g      }t	               5  t        d | j                  d| j                  z        j                  d      D              }ddd       | j                  |       y# 1 sw Y   xY w)z5Tests matching with both bucket and object wildcards.r   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zLCloudWildcardIteratorTests.testWildcardBucketAndObjectUri.<locals>.<genexpr>   s        IHQ#a& Hr[   z	%s0*/abc*TrQ   N)	r*   rC   r)   rS   r   r?   r'   rT   rA   r^   s      r7   testWildcardBucketAndObjectUriz9CloudWildcardIteratorTests.testWildcardBucketAndObjectUri   s    	T""55f=	>?A	#	%  I66 !!($!GH I I 
&
 	%':; 
&	%s   ?BBc                    t        t        | j                  j                  d            g      }t        d | j	                  d| j                  j
                  z        j                  d      D              }| j                  ||       y)zTests wildcard subd*r/obj name.r   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   z[CloudWildcardIteratorTests.testWildcardUpToFinalCharSubdirPlusObjectName.<locals>.<genexpr>         ON1A Nr[   z%snested1/nest*2/xyz1TrQ   Nr*   rC   r)   rS   r?   r   rT   rA   r^   s      r7   -testWildcardUpToFinalCharSubdirPlusObjectNamezHCloudWildcardIteratorTests.testWildcardUpToFinalCharSubdirPlusObjectName  s    	T""556LM	NOQ O44#!!%%&''.ww'MNO O 	%':;r8   c                    t        t        | j                  j                  d            g      }t        d | j	                  d| j                  j
                  z        j                  d      D              }| j                  ||       y)z@Tests wildcard containing ** followed by an additional wildcard.r   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zGCloudWildcardIteratorTests.testPostRecursiveWildcard.<locals>.<genexpr>  r   r[   z	%s**/*y*2TrQ   Nr   r^   s      r7   testPostRecursiveWildcardz4CloudWildcardIteratorTests.testPostRecursiveWildcard  s    	T""556LM	NOQ O44!!%%&''.ww'MNO O 	%':;r8   c                    t        d | j                  | j                  j                  d            j	                  dg      D              }| j                  t        |             |D ]5  }| j                  |j                  xr |j                  j                         7 t        d | j                  | j                  j                  d            j	                  dg      D              }| j                  t        |             |D ]6  }| j                  |j                  xr |j                  j                          8 y)zBTests that wildcard w/fields specification returns correct fields.c              3       K   | ]  }|  y wrI    rL   s     r7   rO   z@CloudWildcardIteratorTests.testWildcardFields.<locals>.<genexpr>  s      4 3Qq 3   rP   timeCreated)bucket_listing_fieldsc              3       K   | ]  }|  y wrI   r   rL   s     r7   rO   z@CloudWildcardIteratorTests.testWildcardFields.<locals>.<genexpr>  s      3 2Qq 2r   
generationN)	r*   r?   r)   rS   rT   rp   rB   rn   r   )r2   blrsrs   s      r7   testWildcardFieldsz-CloudWildcardIteratorTests.testWildcardFields  s    4$6600688?#0/ 9@ 933 4 4D 	OOCI
oocooE#//*E*EF  3$6600688?#/. 9@ 922 3 3D 	OOCI
oocooIcoo.I.I*IJ r8   c                    t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  j                  d      j                  | j                  j                  d      j                  g      }t               }| j                  ||       | j                  ||       y)rw   z**/xyz*r   r   Nr   rx   s         r7   *testDoesNotStripDelimiterForDoubleWildcardzECloudWildcardIteratorTests.testDoesNotStripDelimiterForDoubleWildcard%  s    eOeO++00;=	COO,CNN+= 001GHLL001GHLL  &8&8r8   c                    t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  j                  d      j                  | j                  j                  d      j                  | j                  j                  d      j                  | j                  j                  d      j                  g      }t               }| j                  ||       | j                  ||       y)z%Tests gs://bucket/**/object matching.z**/f.txtr   r   r   r   N
r*   r?   r0   rS   rm   r-   rn   ro   r   rA   rx   s         r7   testDoubleWildcardAfterBucketz8CloudWildcardIteratorTests.testDoubleWildcardAfterBucket7  s   eOeO++00<>	COO,CNN+> 009==00@DD001CDHH001CDHH	  &8&8r8   c                 b   t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  j                  d      j                  | j                  j                  d      j                  | j                  j                  d      j                  g      }t               }| j                  ||       | j                  ||       y)z)Tests gs://bucket/dir/**/object matching.zdouble/**/f.txtr   r   r   Nr   rx   s         r7   testDoubleWildcardAfterPrefixz8CloudWildcardIteratorTests.testDoubleWildcardAfterPrefixK  s    eOeO++001BCE	COO,CNN+E 00@DD001CDHH001CDHH 
 &8&8r8   c                 b   t               }t               }| j                  | j                  j                  d            D ]I  }|j	                         r|j                  |j                         /|j                  |j                         K t        | j                  j                  d      j                  | j                  j                  d      j                  | j                  j                  d      j                  g      }t               }| j                  ||       | j                  ||       y)z,Tests gs://bucket/**/dir/**/object matching.z**/double/**/f.txtr   r   r   Nr   rx   s         r7   &testDoubleWildcardBeforeAndAfterPrefixzACloudWildcardIteratorTests.testDoubleWildcardBeforeAndAfterPrefix^  s    eOeO++001EFH	COO,CNN+H 00@DD001CDHH001CDHH 
 &8&8r8   )__name__
__module____qualname____doc__r    rF   rV   r`   rc   ri   ru   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r6   s   @r7   r   r   *   st    -48lBJ
<<? , 99$"C
<<	<<<K9$9(9&9r8   r   c                   v     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Z xZS )FileIteratorTestsz$Unit tests for FileWildcardIterator.c                 
   t         t        |           | j                  g d      | _        t        t        | j                  d      t        | j                  d      t        | j                  d      g      | _        t        t        | j                  d      g      | _        t        t        | j                  ddd      g      | _	        | j                  | j                  z  | _
        | j                  | j                  z  | _        y	)
zCCreates a test dir with 3 files and one nested subdirectory + file.)r   r   r   )dir1dir2zzz)
test_filesr   r   r   r   r   r   N)r   r   r    CreateTempDirtest_dirr*   r&   root_files_uri_strssubdirs_uri_strsnested_files_uri_strsimmed_child_uri_strsall_file_uri_strs)r2   r6   s    r7   r    zFileIteratorTests.setUpu  s    	
T(*&&D ' FDM  #T]]F#T]]F#T]]F#$  D  dmmV!< =>D!$	dmmVVU	34"6D !% 8 84;P;P PD"66"889Dr8   c                     | j                  t        d             | j                  t        d             | j                  t        d             | j                  t        d             y)zTests ContainsWildcard call.za*.txtz
a[0-9].txtz0-9.txtz?.txtN)rp   r	   r   )r2   s    r7   testContainsWildcardz&FileIteratorTests.testContainsWildcard  sL    OO$X./OO$\23%i01OO$W-.r8   c                 &   t        | j                  t        t        j                              j                  d            }| j                  dt        |             | j                  t        t        j                        t        |d                y)z9Tests that directory-only URI iterates just that one URI.TrQ   r=   r   N)	r>   r?   r&   tempfiletempdirrT   rA   rB   rC   rD   s     r7   testNoOpDirectoryIteratorz+FileIteratorTests.testNoOpDirectoryIterator  sp    $$T& 	&wwEGG 	QG%T(**+S_=r8   c                     | j                  t        | j                  d            }t        d | j	                  |      j                  d      D              }| j                  | j                  |       y),Tests matching all files, based on wildcard.rk   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   z9FileIteratorTests.testMatchingAllFiles.<locals>.<genexpr>        ,+1A +r[   TrQ   N)_test_storage_urir&   r   r*   r?   rT   rA   r   r2   r   ry   s      r7   testMatchingAllFilesz&FileIteratorTests.testMatchingAllFiles  sk    

 
 dmmS!9
:C ,44S9AA%) B +, ,O 	T..@r8   c                    | j                  t        | j                  d            }| j                  |      j	                  ddg      }d}d}|D ]d  }| j                  t        |      | j                  v        |j                         s:|dz  }| j                  |j                  j                  d       f | j                  ||       y	)
r   rk   Tsize)rR   r      r   r=      N)r   r&   r   r?   rT   rp   rC   r   IsObjectrA   rn   r   )r2   r   r   num_expected_objectsnum_actual_objectsrs   s         r7   testMatchingAllFilesWithSizez.FileIteratorTests.testMatchingAllFilesWithSize  s    

 
 dmmS!9
:C'',44!%fX 5 GD
ooc#h$";";;<	a--q1  	)+=>r8   c                 >   t        t        | j                  d      t        | j                  d      g      }| j                  t        | j                  d            }t        d | j	                  |      j                  d      D              }| j                  ||       y)z4Tests matching a subset of files, based on wildcard.r   r   r\   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   z;FileIteratorTests.testMatchingFileSubset.<locals>.<genexpr>  r   r[   TrQ   Nr*   r&   r   r   r?   rT   rA   r2   exp_uri_strsr   ry   s       r7   testMatchingFileSubsetz(FileIteratorTests.testMatchingFileSubset  s    	dmmV	$	dmmV	$	&'L 
 
 dmmV!<
=C ,44S9AA%) B +, ,O 	\?3r8   c                    t        t        | j                  d      g      }| j                  t        | j                  d            }t        d | j	                  |      j                  d      D              }| j                  ||       y)z#Tests matching a single named file.r   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zAFileIteratorTests.testMatchingNonWildcardedUri.<locals>.<genexpr>  r   r[   TrQ   Nr   r   s       r7   rc   z.FileIteratorTests.testMatchingNonWildcardedUri  s}    T]]F345L

 
 dmmV!<
=C ,44S9AA%) B +, ,O 	\?3r8   c                    t        t        | j                  d      g      }| j                  t        | j                  d            }t        d | j	                  |      j                  d      D              }| j                  ||       y)z8Tests ignoring non-wildcard regex chars (e.g., ^ and $).r   zad*$c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zMFileIteratorTests.testMatchingFilesIgnoringOtherRegexChars.<locals>.<genexpr>  r   r[   TrQ   Nr   r   s       r7   (testMatchingFilesIgnoringOtherRegexCharsz:FileIteratorTests.testMatchingFilesIgnoringOtherRegexChars  s     T]]F345L

 
 dmmV!<
=C ,44S9AA%) B +, ,O 	\?3r8   c                     | j                  t        | j                  d            }t        d | j	                  |      j                  d      D              }| j                  | j                  |       y)z:Tests recursive expansion of directory-only '**' wildcard.rP   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zJFileIteratorTests.testRecursiveDirectoryOnlyWildcarding.<locals>.<genexpr>  r   r[   TrQ   Nr   r&   r   r*   r?   rT   rA   r   r   s      r7   %testRecursiveDirectoryOnlyWildcardingz7FileIteratorTests.testRecursiveDirectoryOnlyWildcarding  sk    

 
 dmmT!:
;C ,44S9AA%) B +, ,O 	T++_=r8   c                     | j                  t        | j                  dd            }t        d | j	                  |      j                  d      D              }| j                  | j                  |       y)z>Tests recursive expansion of '**' directory plus '*' wildcard.rP   rk   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zNFileIteratorTests.testRecursiveDirectoryPlusFileWildcarding.<locals>.<genexpr>  r   r[   TrQ   Nr   r   s      r7   )testRecursiveDirectoryPlusFileWildcardingz;FileIteratorTests.testRecursiveDirectoryPlusFileWildcarding  sm    

 
 dmmT3!?
@C ,44S9AA%) B +, ,O 	T++_=r8   c                 X   	 | j                  t        | j                  dd            }| j                  |      j	                  d      D ]  }| j                  d        y# t        j                  $ r6}| j                  t        |      j                  d      dk7         Y d}~yd}~ww xY w)	z6Tests that wildcard containing '***' raises exception.z***r   TrQ   z&Expected WildcardException not raised.zmore than 2 consecutiver   N)r   r&   r   r?   rT   failr   WildcardExceptionrp   rC   r   )r2   r   r   r   s       r7   %testInvalidRecursiveDirectoryWildcardz7FileIteratorTests.testInvalidRecursiveDirectoryWildcard  s    D""4uf#EFc11#6>>#' ? )'		:;) .. D
ooc!fkk";<BCCDs   AA   B)3,B$$B)c                     t        | j                  t        dd            j                  d            }| j	                  dt        |             y)zETests that wildcard gets empty iterator when directory doesn't exist.no_such_dirrk   TrQ   r   N)r>   r?   r&   rT   rA   rB   r   s     r7   testMissingDirz FileIteratorTests.testMissingDir  sI    
$$T3&  	!!($!GIC 	QC!r8   c                     | j                  t        | j                  d            }t        | j	                  |      j                  d            }| j                  dt        |             y)zATests that wildcard returns empty iterator when there's no match.znon_existent*TrQ   r   N)r   r&   r   r>   r?   rT   rA   rB   )r2   r   r   s      r7   testExistingDirNoFileMatchz,FileIteratorTests.testExistingDirNoFileMatch  s^    

 
 dmm_!E
FC
$$S)11%) 	2 	+,C 	QC!r8   c                 F   | j                   }| j                  t        | j                  d            }t	        | j                        dt        j                  d      f}t        d | j                  ||      j                  d      D              }| j                  ||       y)z:Tests that the exclude regex will omit a nested directory.rP   Tr   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   z3FileIteratorTests.testExcludeDir.<locals>.<genexpr>         0/A 	A/r[   exclude_tuplerQ   N)r   r   r&   r   r
   recompiler*   r?   rT   rA   r2   r   r   r   ry   s        r7   testExcludeDirz FileIteratorTests.testExcludeDir  s    ++L

 
 dmmT!:
;C)$--8$ZZ')M 0--c-O./0 0O 	\?3r8   c                 F   | j                   }| j                  t        | j                  d            }t	        | j                        dt        j                  d      f}t        d | j                  ||      j                  d      D              }| j                  ||       y)	zCTests that the exclude regex will be disabled by exlude_dirs False.rP   Fr   c              3   2   K   | ]  }t        |        y wrI   rY   rL   s     r7   rO   zGFileIteratorTests.testExcludeTupleButExcludeDirFalse.<locals>.<genexpr>  r   r[   r   TrQ   N)r   r   r&   r   r
   r   r   r*   r?   rT   rA   r   s        r7   "testExcludeTupleButExcludeDirFalsez4FileIteratorTests.testExcludeTupleButExcludeDirFalse  s    ))L

 
 dmmT!:
;C)$--8%ZZ')M 0--c-O./0 0O 	\?3r8   )r   r   r   r   r    r   r   r   r   r   rc   r   r   r   r   r   r   r   r  r   r   s   @r7   r   r   r  sS    ,:,/>A?	444>>	D""
4
4r8   r   )r   
__future__r   r   r   r   r   rJ   r   gslibr   gslib.exceptionr   gslib.storage_urlr	   r
   gslib.tests.testcaseteststestcasegslib.tests.utilr   r&   r   GsUtilUnitTestCaser   r   r   r8   r7   <module>r     s`   , / & %  ' 	 
  # + . 2 ' ' 0 7E9!<!< E9P
]433 ]4r8   