Skip to content

Commit 7090cc1

Browse files
committed
frontend_file as read
1 parent e6ff518 commit 7090cc1

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

opengeodeweb_back_schemas.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,17 @@
343343
"required": [],
344344
"additionalProperties": false
345345
},
346+
"import_extension": {
347+
"$id": "opengeodeweb_back/import_extension",
348+
"route": "/import_extension",
349+
"methods": [
350+
"POST"
351+
],
352+
"type": "object",
353+
"properties": {},
354+
"required": [],
355+
"additionalProperties": false
356+
},
346357
"geographic_coordinate_systems": {
347358
"$id": "opengeodeweb_back/geographic_coordinate_systems",
348359
"route": "/geographic_coordinate_systems",

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,19 @@ def import_extension() -> flask.Response:
566566

567567
if not frontend_file:
568568
flask.abort(400, "Invalid .vext file: missing frontend JavaScript")
569-
570569
if not backend_executable:
571570
flask.abort(400, "Invalid .vext file: missing backend executable")
572571

572+
# Read the frontend JS content
573+
assert frontend_file is not None
574+
with open(frontend_file, "r", encoding="utf-8") as f:
575+
frontend_content = f.read()
576+
573577
return flask.make_response(
574578
{
575579
"extension_name": extension_name,
576-
"frontend_path": frontend_file,
580+
"frontend_content": frontend_content,
577581
"backend_path": backend_executable,
578-
"extension_folder": extension_path,
579582
},
580583
200,
581584
)

src/opengeodeweb_back/routes/schemas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from .kill import *
1010
from .inspect_file import *
1111
from .import_project import *
12+
from .import_extension import *
1213
from .geographic_coordinate_systems import *
1314
from .geode_objects_and_output_extensions import *
1415
from .export_project import *
1516
from .cell_attribute_names import *
1617
from .allowed_objects import *
1718
from .allowed_files import *
18-
from .import_extension import *

tests/test_models_routes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ def test_import_extension_route(client: FlaskClient, tmp_path: Path) -> None:
211211
assert response.status_code == 200
212212
json_data = response.get_json()
213213
assert "extension_name" in json_data
214-
assert "frontend_path" in json_data
214+
assert "frontend_content" in json_data
215215
assert "backend_path" in json_data
216-
assert "extension_folder" in json_data
217216
assert json_data["extension_name"] == "test-extension"
218217
extensions_folder = os.path.join(
219218
client.application.config["DATA_FOLDER_PATH"], "extensions"
@@ -222,9 +221,13 @@ def test_import_extension_route(client: FlaskClient, tmp_path: Path) -> None:
222221
assert os.path.exists(extension_path)
223222
dist_path = os.path.join(extension_path, "dist")
224223
assert os.path.exists(dist_path)
225-
frontend_js = json_data["frontend_path"]
226-
assert os.path.exists(frontend_js)
227-
assert frontend_js.endswith("-extension.es.js")
224+
225+
# Verify frontend content is returned
226+
frontend_content = json_data["frontend_content"]
227+
assert isinstance(frontend_content, str)
228+
assert len(frontend_content) > 0
229+
assert "export const metadata" in frontend_content
230+
228231
backend_exec = json_data["backend_path"]
229232
assert os.path.exists(backend_exec)
230233
assert os.access(backend_exec, os.X_OK)

0 commit comments

Comments
 (0)