@@ -32,48 +32,34 @@ def test_config(path):
3232 tmp_data_root = tempfile .mkdtemp (prefix = "ogw_test_data_" )
3333 os .environ ["DATA_FOLDER_PATH" ] = tmp_data_root
3434
35- original_data_path = os .path .join (path , "data" )
36- if not os .path .exists (original_data_path ):
37- raise FileNotFoundError (f"Test data folder not found: { original_data_path } " )
38-
39- valid_extensions = {".vtp" , ".vti" , ".vtu" , ".vtm" , ".png" , ".jpeg" , ".jpg" }
35+ src_data = os .path .join (path , "data" )
36+ if not os .path .isdir (src_data ):
37+ raise FileNotFoundError (f"Test data folder not found: { src_data } " )
4038
4139 test_ids = ["123456789" , "12345678" ]
40+ valid_exts = {".vtp" , ".vti" , ".vtu" , ".vtm" , ".png" , ".jpeg" , ".jpg" }
4241
43- for test_id in test_ids :
44- test_id_dir = os .path .join (tmp_data_root , test_id )
45- os .makedirs (test_id_dir , exist_ok = True )
46-
47- test_project_uuid = "test-project-uuid"
48- test_data_uuid = "test-data-uuid"
49- new_structure_dir = os .path .join (tmp_data_root , test_project_uuid , test_data_uuid )
50- os .makedirs (new_structure_dir , exist_ok = True )
42+ project_uuid = "test-project-uuid"
43+ data_uuid = "test-data-uuid"
44+ uploads_directory = os .path .join (tmp_data_root , project_uuid , "uploads" )
45+ structure_directory = os .path .join (tmp_data_root , project_uuid , data_uuid )
5146
52- uploads_dir = os . path . join ( tmp_data_root , test_project_uuid , "uploads" )
53- os .makedirs (uploads_dir , exist_ok = True )
47+ for directory in [ * test_ids , uploads_directory , structure_directory ]: # create directories for tests
48+ os .makedirs (os . path . join ( tmp_data_root , directory ) if isinstance ( directory , str ) else directory , exist_ok = True )
5449
55- for root , dirs , files in os .walk (original_data_path ):
56- for d in dirs :
57- src_dir = os .path .join (root , d )
58- dst_dir = os .path .join (tmp_data_root , test_ids [0 ], d )
59- if not os .path .exists (dst_dir ):
60- copytree (src_dir , dst_dir , dirs_exist_ok = True )
50+ for root , directories , files in os .walk (src_data ):
51+ for directory in directories :
52+ dst = os .path .join (tmp_data_root , test_ids [0 ], directory )
53+ copytree (os .path .join (root , directory ), dst , dirs_exist_ok = True )
6154
62- for file_name in files :
63- ext = os .path .splitext (file_name )[1 ].lower ()
64- if ext not in valid_extensions :
55+ for file in files :
56+ if os .path .splitext (file )[1 ].lower () not in valid_exts :
6557 continue
6658
67- full_path = os .path .join (root , file_name )
68-
59+ src = os .path .join (root , file )
6960 for test_id in test_ids :
70- test_id_dst = os .path .join (tmp_data_root , test_id , file_name )
71- copyfile (full_path , test_id_dst )
72-
73- new_structure_dst = os .path .join (new_structure_dir , file_name )
74- copyfile (full_path , new_structure_dst )
75-
76- uploads_dst = os .path .join (uploads_dir , file_name )
77- copyfile (full_path , uploads_dst )
61+ copyfile (src , os .path .join (tmp_data_root , test_id , file ))
62+ copyfile (src , os .path .join (structure_directory , file ))
63+ copyfile (src , os .path .join (uploads_directory , file ))
7864
79- print (f"\n ✅ DATA_FOLDER_PATH set to: { tmp_data_root } " , flush = True )
65+ print (f"\n DATA_FOLDER_PATH set to: { tmp_data_root } " , flush = True )
0 commit comments