66from werkzeug .datastructures import FileStorage
77
88# Local application imports
9+ from opengeodeweb_microservice .microservice .data import Data
10+ from opengeodeweb_microservice .database .connection import get_session
911from src .opengeodeweb_back import geode_functions , test_utils
1012
1113
@@ -171,16 +173,15 @@ def test_texture_coordinates(client, test_id):
171173 with client .application .app_context ():
172174 data = Data .create (geode_object = "PolygonalSurface3D" , input_file = "hat.vtp" )
173175 data .native_file_name = "hat.vtp"
176+ session = get_session ()
177+ if session :
178+ session .commit ()
174179
175- data_path = geode_functions .data_file_path (data .id , "hat.vtp" )
176- print (data_path )
180+ data_path = geode_functions .data_file_path (data .id , data .native_file_name )
177181 os .makedirs (os .path .dirname (data_path ), exist_ok = True )
178182 shutil .copy ("./tests/data/hat.vtp" , data_path )
179-
180- response = client .post (
181- "/texture_coordinates" ,
182- json = {"id" : data .id },
183- )
183+ assert os .path .exists (data_path ), f"File not found at { data_path } "
184+ response = client .post ("/texture_coordinates" , json = {"id" : data .id })
184185 assert response .status_code == 200
185186 texture_coordinates = response .json ["texture_coordinates" ]
186187 assert type (texture_coordinates ) is list
@@ -194,12 +195,14 @@ def test_vertex_attribute_names(client, test_id):
194195 with client .application .app_context ():
195196 data = Data .create (geode_object = "PolygonalSurface3D" , input_file = "test.vtp" )
196197 data .native_file_name = "test.vtp"
198+ session = get_session ()
199+ if session :
200+ session .commit ()
197201
198- data_path = geode_functions .data_file_path (data .id , "test.vtp" )
202+ data_path = geode_functions .data_file_path (data .id , data . native_file_name )
199203 os .makedirs (os .path .dirname (data_path ), exist_ok = True )
200- if os .path .exists ("./tests/data/hat.vtp" ):
201- shutil .copy ("./tests/data/hat.vtp" , data_path )
202-
204+ shutil .copy ("./tests/data/test.vtp" , data_path )
205+ assert os .path .exists (data_path ), f"File not found at { data_path } "
203206 response = client .post (route , json = {"id" : data .id })
204207 assert response .status_code == 200
205208 vertex_attribute_names = response .json ["vertex_attribute_names" ]
@@ -214,11 +217,14 @@ def test_polygon_attribute_names(client, test_id):
214217 with client .application .app_context ():
215218 data = Data .create (geode_object = "PolygonalSurface3D" , input_file = "test.vtp" )
216219 data .native_file_name = "test.vtp"
220+ session = get_session ()
221+ if session :
222+ session .commit ()
217223
218- data_path = geode_functions .data_file_path (data .id , "test.vtp" )
224+ data_path = geode_functions .data_file_path (data .id , data . native_file_name )
219225 os .makedirs (os .path .dirname (data_path ), exist_ok = True )
220- shutil .copy ("./tests/data/test.vtp" , data_path )
221-
226+ shutil .copy ("./tests/data/test.vtp" , data_path )
227+ assert os . path . exists ( data_path ), f"File not found at { data_path } "
222228 response = client .post (route , json = {"id" : data .id })
223229 assert response .status_code == 200
224230 polygon_attribute_names = response .json ["polygon_attribute_names" ]
@@ -233,12 +239,16 @@ def test_polyhedron_attribute_names(client, test_id):
233239 with client .application .app_context ():
234240 data = Data .create (geode_object = "PolyhedralSolid3D" , input_file = "test.vtu" )
235241 data .native_file_name = "test.vtu"
242+ session = get_session ()
243+ if session :
244+ session .commit ()
236245
237- data_path = geode_functions .data_file_path (data .id , "test.vtu" )
246+ data_path = geode_functions .data_file_path (data .id , data . native_file_name )
238247 os .makedirs (os .path .dirname (data_path ), exist_ok = True )
239248 shutil .copy ("./tests/data/test.vtu" , data_path )
240-
249+ assert os . path . exists ( data_path ), f"File not found at { data_path } "
241250 response = client .post (route , json = {"id" : data .id })
251+ print (response .json )
242252 assert response .status_code == 200
243253 polyhedron_attribute_names = response .json ["polyhedron_attribute_names" ]
244254 assert type (polyhedron_attribute_names ) is list
0 commit comments