
    	]jS	                         d dl Z d dlmZ e j                  j                  Zd dlmZ e j                  j                  dddg      d        Z	y)    N)LABEL_CONFIG_AND_TASKS)LabelStudiorecursive_scanTFc                    t        | |j                        }|j                  j                  dt        d         }|j
                  j                  j                  |j                  ddd|      }|j                  }|j
                  j                  j                  |	      }|j                  |j                  k(  sJ |j                  dk(  sJ |j                  du sJ |j                  |k(  sJ |j
                  j                  j                  |d
       |j
                  j                  j                  |	      }|j                  d
u sJ |j
                  j                  j                  |	      }|j                  dv sJ g }	|j                   j#                  |j                        D ]  }
|	j%                  |
        |rh d}ndh}t'        d |	D              |k(  sJ y)a:  Test S3 storage connection and sync with recursive scan parameter.

    This test validates step by step:
    - Creating a project with labeling configuration
    - Setting up S3 import storage with recursive_scan parameter
    - Verifying storage configuration and updates
    - Triggering sync operation
    - Validating task creation based on recursive_scan setting

    Critical validation: When recursive_scan=False, only files in the root
    directory should be imported (image1.jpg), while recursive_scan=True
    imports all files including subdirectories.
    )base_urlapi_keyzNew Projectlabel_config)titler	   zpytest-s3-imagesz.*F)projectbucketregex_filteruse_blob_urlsr   )idT)r   r   )initializedqueued	completed)r   >   subdir/image1.jpgsubdir/image2.jpgsubdir/another/image2.jpg
image1.jpgr   c              3   4   K   | ]  }|j                     y w)N)storage_filename).0ts     N/root/env/lib/python3.12/site-packages/label_studio/tests/sdk/test_storages.py	<genexpr>z+test_connect_and_sync_s3.<locals>.<genexpr>?   s     1aq!!1s   N)r   r   projectscreater   import_storages3r   getr   r   r   r   updatesyncstatustaskslistappendset)django_live_urlbusiness_clientr   lspstorage_resp
storage_idstoragerespr%   taskexpected_filess               r   test_connect_and_sync_s3r3   	   s    
o7N7N	OB
=STb=cdA$$''../dRWhv / L J""&&*&5G??add""">>////  E)))!!^333:TB""&&*&5G  D((($$
$3D;;@@@@Eadd+ T 
 '1511^CCC    )
pytestlabel_studio.tests.sdk.commonr   mark	django_db
pytestmarklabel_studio_sdk.clientr   parametrizer3    r4   r   <module>r=      sI     @[[""
 / )D%=95D :5Dr4   