Skip to content

Commit ef529a5

Browse files
committed
feat(save_viewable): Added tests
1 parent 1b08cf7 commit ef529a5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ def geode_objects_and_output_extensions():
220220
)
221221
def save_viewable_file():
222222
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
223+
geode_functions.validate_request(flask.request, save_viewable_file_json)
224+
223225
secure_filename = werkzeug.utils.secure_filename(flask.request.json["filename"])
224226
file_path = os.path.abspath(os.path.join(UPLOAD_FOLDER, secure_filename))
225227
data = geode_functions.load(flask.request.json["input_geode_object"], file_path)

tests/test_routes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,33 @@ def get_full_data():
155155
assert (
156156
error_message == "Validation error: 'input_geode_object' is a required property"
157157
)
158+
159+
160+
def test_save_viewable_file(client):
161+
route = f"/save_viewable_file"
162+
163+
def get_full_data():
164+
return {
165+
"input_geode_object": "BRep",
166+
"filename": "corbi.og_brep",
167+
}
168+
169+
# Normal test with filename 'corbi.og_brep'
170+
response = client.post(route, json=get_full_data())
171+
assert response.status_code == 200
172+
name = response.json["name"]
173+
assert type(name) is str
174+
native_file_name = response.json["native_file_name"]
175+
assert type(native_file_name) is str
176+
viewable_file_name = response.json["viewable_file_name"]
177+
assert type(viewable_file_name) is str
178+
id = response.json["id"]
179+
assert type(id) is str
180+
181+
for key, value in get_full_data().items():
182+
json = get_full_data()
183+
json.pop(key)
184+
response = client.post(route, json=json)
185+
assert response.status_code == 400
186+
error_description = response.json["description"]
187+
assert error_description == f"Validation error: '{key}' is a required property"

0 commit comments

Comments
 (0)