88# Local application imports
99from src .opengeodeweb_back import test_utils
1010
11+
1112@pytest .fixture
1213def point_data ():
13- return {
14- "title" : "test_point" ,
15- "x" : 1.0 ,
16- "y" : 2.0 ,
17- "z" : 3.0
18- }
14+ return {"title" : "test_point" , "x" : 1.0 , "y" : 2.0 , "z" : 3.0 }
15+
1916
2017@pytest .fixture
2118def aoi_data ():
@@ -25,11 +22,12 @@ def aoi_data():
2522 {"x" : 0.0 , "y" : 0.0 },
2623 {"x" : 1.0 , "y" : 0.0 },
2724 {"x" : 1.0 , "y" : 1.0 },
28- {"x" : 0.0 , "y" : 1.0 }
25+ {"x" : 0.0 , "y" : 1.0 },
2926 ],
30- "z" : 0.0
27+ "z" : 0.0 ,
3128 }
3229
30+
3331def test_create_point (client , point_data ):
3432 """Test the creation of a point with valid data."""
3533 route = "/opengeodeweb_back/create/create_point"
@@ -54,6 +52,7 @@ def test_create_point(client, point_data):
5452 # Test with missing parameters - IMPORTANT: use .copy() to avoid mutation
5553 test_utils .test_route_wrong_params (client , route , lambda : point_data .copy ())
5654
55+
5756def test_create_aoi (client , aoi_data ):
5857 """Test the creation of an AOI with valid data."""
5958 route = "/opengeodeweb_back/create/create_aoi"
@@ -78,29 +77,22 @@ def test_create_aoi(client, aoi_data):
7877 # Test with missing parameters - IMPORTANT: use .copy() to avoid mutation
7978 test_utils .test_route_wrong_params (client , route , lambda : aoi_data .copy ())
8079
80+
8181def test_create_point_with_invalid_data (client ):
8282 """Test the point creation endpoint with invalid data."""
8383 route = "/opengeodeweb_back/create/create_point"
8484
8585 # Test with non-numeric coordinates
86- invalid_data = {
87- "title" : "invalid_point" ,
88- "x" : "not_a_number" ,
89- "y" : 2.0 ,
90- "z" : 3.0
91- }
86+ invalid_data = {"title" : "invalid_point" , "x" : "not_a_number" , "y" : 2.0 , "z" : 3.0 }
9287 response = client .post (route , json = invalid_data )
9388 assert response .status_code == 400
9489
9590 # Test with missing coordinates
96- invalid_data = {
97- "title" : "invalid_point" ,
98- "y" : 2.0 ,
99- "z" : 3.0
100- }
91+ invalid_data = {"title" : "invalid_point" , "y" : 2.0 , "z" : 3.0 }
10192 response = client .post (route , json = invalid_data )
10293 assert response .status_code == 400
10394
95+
10496def test_create_aoi_with_invalid_data (client , aoi_data ):
10597 """Test the AOI creation endpoint with invalid data."""
10698 route = "/opengeodeweb_back/create/create_aoi"
@@ -112,31 +104,23 @@ def test_create_aoi_with_invalid_data(client, aoi_data):
112104 {"x" : "not_a_number" , "y" : 0.0 },
113105 {"x" : 1.0 , "y" : 0.0 },
114106 {"x" : 1.0 , "y" : 1.0 },
115- {"x" : 0.0 , "y" : 1.0 }
116- ]
107+ {"x" : 0.0 , "y" : 1.0 },
108+ ],
117109 }
118110 response = client .post (route , json = invalid_data )
119111 assert response .status_code == 400
120112
121113 # Test with too few points
122- invalid_data = {
123- ** aoi_data ,
124- "points" : [
125- {"x" : 0.0 , "y" : 0.0 },
126- {"x" : 1.0 , "y" : 0.0 }
127- ]
128- }
114+ invalid_data = {** aoi_data , "points" : [{"x" : 0.0 , "y" : 0.0 }, {"x" : 1.0 , "y" : 0.0 }]}
129115 response = client .post (route , json = invalid_data )
130116 assert response .status_code == 400
131117
132118 # Test with invalid z value
133- invalid_data = {
134- ** aoi_data ,
135- "z" : "not_a_number"
136- }
119+ invalid_data = {** aoi_data , "z" : "not_a_number" }
137120 response = client .post (route , json = invalid_data )
138121 assert response .status_code == 400
139122
123+
140124def test_create_point_file_generation (client , point_data ):
141125 """Test that the point creation generates the correct files."""
142126 route = "/opengeodeweb_back/create/create_point"
@@ -172,6 +156,7 @@ def test_create_point_file_generation(client, point_data):
172156 assert response_data ["native_file_name" ].endswith (".og_pts3d" )
173157 assert response_data ["viewable_file_name" ].endswith (".vtp" )
174158
159+
175160def test_create_aoi_file_generation (client , aoi_data ):
176161 """Test that the AOI creation generates the correct files."""
177162 route = "/opengeodeweb_back/create/create_aoi"
0 commit comments