Skip to content

Commit 6532d82

Browse files
committed
add test for curve
1 parent ec89a87 commit 6532d82

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/test_create_routes.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ def point_data() -> test_utils.JsonData:
1414
return {"name": "test_point", "points": [{"x": 1.0, "y": 2.0, "z": 3.0}]}
1515

1616

17+
@pytest.fixture
18+
def curve_data() -> test_utils.JsonData:
19+
return {
20+
"name": "test_curve",
21+
"points": [{"x": 0.0, "y": 0.0, "z": 0.0}, {"x": 1.0, "y": 1.0, "z": 1.0}],
22+
"edges": [[0, 1]],
23+
}
24+
25+
1726
def test_create_point(client: FlaskClient, point_data: test_utils.JsonData) -> None:
1827
"""Test the creation of a point with valid data."""
1928
route: str = "/opengeodeweb_back/create/point_set"
@@ -55,3 +64,27 @@ def test_create_point_with_invalid_data(client: FlaskClient) -> None:
5564
invalid_data = {"name": "invalid_point", "points": [{"y": 2.0, "z": 3.0}]}
5665
response = client.post(route, json=invalid_data)
5766
assert response.status_code == 400
67+
68+
def test_create_curve(client: FlaskClient, curve_data: test_utils.JsonData) -> None:
69+
"""Test the creation of a curve with valid data."""
70+
route: str = "/opengeodeweb_back/create/edged_curve"
71+
72+
# Test with all required data
73+
response = client.post(route, json=curve_data)
74+
assert response.status_code == 200
75+
76+
# Verify response data
77+
response_data = response.get_json()
78+
assert "viewable_file" in response_data
79+
assert "id" in response_data
80+
assert "name" in response_data
81+
assert "native_file" in response_data
82+
assert "viewer_type" in response_data
83+
assert "geode_object_type" in response_data
84+
85+
assert response_data["name"] == curve_data["name"]
86+
assert response_data["viewer_type"] == "mesh"
87+
assert response_data["geode_object_type"] == "EdgedCurve3D"
88+
89+
# Test with missing parameters
90+
test_utils.test_route_wrong_params(client, route, lambda: copy.deepcopy(curve_data))

0 commit comments

Comments
 (0)