@@ -66,6 +66,11 @@ def test_export_project_route(client, tmp_path):
6666 "styles" : {"1" : {"visibility" : True , "opacity" : 1.0 , "color" : [0.2 , 0.6 , 0.9 ]}}
6767 }
6868 filename = "export_project_test.zip"
69+ project_folder = client .application .config ["DATA_FOLDER_PATH" ]
70+ os .makedirs (project_folder , exist_ok = True )
71+ database_root_path = os .path .join (project_folder , "project.db" )
72+ with open (database_root_path , "wb" ) as f :
73+ f .write (b"test_project_db" )
6974 response = client .post (route , json = {"snapshot" : snapshot , "filename" : filename })
7075 assert response .status_code == 200
7176 assert response .headers .get ("new-file-name" ) == filename
@@ -79,10 +84,9 @@ def test_export_project_route(client, tmp_path):
7984 assert "snapshot.json" in names
8085 parsed = json .loads (zip_file .read ("snapshot.json" ).decode ("utf-8" ))
8186 assert parsed == snapshot
82- assert "1/ project.db" in names
87+ assert "project.db" in names
8388 response .close ()
84- upload_folder = client .application .config ["UPLOAD_FOLDER" ]
85- export_path = os .path .join (upload_folder , filename )
89+ export_path = os .path .join (project_folder , filename )
8690 if os .path .exists (export_path ):
8791 os .remove (export_path )
8892
@@ -93,17 +97,15 @@ def test_import_project_route(client, tmp_path):
9397 "styles" : {"1" : {"visibility" : True , "opacity" : 1.0 , "color" : [0.2 , 0.6 , 0.9 ]}}
9498 }
9599
100+ client .application .config ["DATA_FOLDER_PATH" ] = os .path .join (str (tmp_path ), "project_data" )
96101 data_folder = client .application .config ["DATA_FOLDER_PATH" ]
97- pre_existing_db_path = os .path .join (data_folder , "1" , "project.db" )
98- os .makedirs (os .path .dirname (pre_existing_db_path ), exist_ok = True )
99- with open (pre_existing_db_path , "wb" ) as file :
100- file .write (b"old_db_content" )
102+ pre_existing_db_path = os .path .join (data_folder , "project.db" )
101103
102104 tmp_zip = tmp_path / "import_project_test.zip"
103105 new_database_bytes = b"new_db_content"
104106 with zipfile .ZipFile (tmp_zip , "w" , compression = zipfile .ZIP_DEFLATED ) as zip_file :
105107 zip_file .writestr ("snapshot.json" , json .dumps (snapshot ))
106- zip_file .writestr ("1/ project.db" , new_database_bytes )
108+ zip_file .writestr ("project.db" , new_database_bytes )
107109
108110 with open (tmp_zip , "rb" ) as file :
109111 response = client .post (
0 commit comments