77def default_config ():
88 os .environ ["DEFAULT_HOST" ] = "localhost"
99 os .environ ["DEFAULT_PORT" ] = "1234"
10- os .environ ["DATABASE_PATH" ] = os .path .join (
11- os .environ .get ("DATA_FOLDER_PATH" , "/data/" ), "project.db"
12- )
1310
1411
1512def prod_config ():
1613 default_config ()
1714 os .environ ["DATA_FOLDER_PATH" ] = "/data/"
18- os .environ ["DATABASE_PATH" ] = os .path .join ("/data/" , "project.db" )
1915
2016
2117def dev_config ():
2218 default_config ()
2319 if platform == "linux" :
2420 os .environ ["DATA_FOLDER_PATH" ] = "/temp/OpenGeodeWeb_Data/"
2521 elif platform == "win32" :
26- os .environ ["DATA_FOLDER_PATH" ] = os .path .join (
27- "C:/Users" , os .getlogin (), "OpenGeodeWeb_Data"
28- )
22+ user_home = os .path .expanduser ("~" )
23+ os .environ ["DATA_FOLDER_PATH" ] = os .path .join (user_home , "OpenGeodeWeb_Data" )
2924 if not os .path .exists (os .environ .get ("DATA_FOLDER_PATH" )):
3025 os .mkdir (os .environ .get ("DATA_FOLDER_PATH" ))
31- os .environ ["DATABASE_PATH" ] = os .path .join (
32- os .environ .get ("DATA_FOLDER_PATH" ), "project.db"
33- )
3426
27+ def _copy_test_assets (src_data : str , tmp_data_root : str , test_ids : list [str ], valid_exts : set [str ], uploads_directory : str , structure_directory : str ):
28+ for root , directories , files in os .walk (src_data ):
29+ for directory in directories :
30+ for test_id in test_ids :
31+ dst = os .path .join (tmp_data_root , test_id , directory )
32+ copytree (os .path .join (root , directory ), dst , dirs_exist_ok = True )
33+ for file in files :
34+ if os .path .splitext (file )[1 ].lower () not in valid_exts :
35+ continue
36+ src = os .path .join (root , file )
37+ for test_id in test_ids :
38+ copyfile (src , os .path .join (tmp_data_root , test_id , file ))
39+ copyfile (src , os .path .join (structure_directory , file ))
40+ copyfile (src , os .path .join (uploads_directory , file ))
3541
3642def test_config (path ):
3743 default_config ()
@@ -43,11 +49,7 @@ def test_config(path):
4349 if not os .path .isdir (src_data ):
4450 raise FileNotFoundError (f"Test data folder not found: { src_data } " )
4551
46- test_ids = [
47- "123456789" ,
48- "12345678" ,
49- ] # needs to match IDs in test_data_helpers.py
50- print (f"Creating test data folders in { tmp_data_root } " , flush = True )
52+ test_ids = ["123456789" , "12345678" , "44556677" , "22334455" , "11223344" , "33445566" , "33445577" ]
5153 valid_exts = {".vtp" , ".vti" , ".vtu" , ".vtm" }
5254
5355 project_uuid = "test-project-uuid"
@@ -69,19 +71,13 @@ def test_config(path):
6971 exist_ok = True ,
7072 )
7173
72- for root , directories , files in os .walk (src_data ):
73- for directory in directories :
74- dst = os .path .join (tmp_data_root , test_ids [0 ], directory )
75- copytree (os .path .join (root , directory ), dst , dirs_exist_ok = True )
76-
77- for file in files :
78- if os .path .splitext (file )[1 ].lower () not in valid_exts :
79- continue
80-
81- src = os .path .join (root , file )
82- for test_id in test_ids :
83- copyfile (src , os .path .join (tmp_data_root , test_id , file ))
84- copyfile (src , os .path .join (structure_directory , file ))
85- copyfile (src , os .path .join (uploads_directory , file ))
74+ _copy_test_assets (
75+ src_data = src_data ,
76+ tmp_data_root = tmp_data_root ,
77+ test_ids = test_ids ,
78+ valid_exts = valid_exts ,
79+ uploads_directory = uploads_directory ,
80+ structure_directory = structure_directory ,
81+ )
8682
87- print (f"\n DATA_FOLDER_PATH set to: { tmp_data_root } " , flush = True )
83+ print (f"\n DATA_FOLDER_PATH set to: { tmp_data_root } " , flush = True )
0 commit comments