From 496d4b9b5e317a99e5ee4fd73bbabb93dcecd17c Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 18 Sep 2025 17:07:42 +0200 Subject: [PATCH 01/21] sql alchemy replacing flask sql alchemy --- app.py | 12 +++++++++++- src/opengeodeweb_back/app_config.py | 3 +-- src/opengeodeweb_back/utils_functions.py | 4 ---- tests/conftest.py | 5 +---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index 3672fe02..93d98b74 100644 --- a/app.py +++ b/app.py @@ -56,8 +56,18 @@ def return_error(): flask.abort(500, f"Test") +def get_db_path_from_config(): + database_uri = app.config.get("SQLALCHEMY_DATABASE_URI", "") + if database_uri.startswith("sqlite:///"): + return database_uri.replace("sqlite:///", "") + return None + + # ''' Main ''' if __name__ == "__main__": - init_database(app) + db_path = get_db_path_from_config() + if db_path: + init_database(db_path) + print(f"Python is running in {FLASK_DEBUG} mode") app.run(debug=FLASK_DEBUG, host=DEFAULT_HOST, port=PORT, ssl_context=SSL) diff --git a/src/opengeodeweb_back/app_config.py b/src/opengeodeweb_back/app_config.py index 453a0eda..96e69745 100644 --- a/src/opengeodeweb_back/app_config.py +++ b/src/opengeodeweb_back/app_config.py @@ -4,9 +4,8 @@ # Third party imports # Local application imports -from opengeodeweb_microservice.database.connection import get_database -DATABASE_FILENAME = "project.db" +DATABASE_FILENAME = "project.db" # Should be declared only once. class Config(object): diff --git a/src/opengeodeweb_back/utils_functions.py b/src/opengeodeweb_back/utils_functions.py index 2830a325..487ad6a9 100644 --- a/src/opengeodeweb_back/utils_functions.py +++ b/src/opengeodeweb_back/utils_functions.py @@ -249,10 +249,6 @@ def generate_native_viewable_and_light_viewable_from_file( data = geode_functions.load(geode_object, copied_full_path) - # Remplacer : - # database.session.delete(temp_data_entry) - # database.session.flush() - # Par : session = get_session() if session: session.delete(temp_data_entry) diff --git a/tests/conftest.py b/tests/conftest.py index e9b41626..2b4f9cc3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,10 +28,7 @@ def copy_data(): print("Current working directory:", os.getcwd()) print("Directory contents:", os.listdir(".")) - init_database(app) - # print(list(app.blueprints.keys())) - # for rule in app.url_map.iter_rules(): - # print(f"Route: {rule.rule} -> {rule.endpoint}") + init_database(db_path) @pytest.fixture From f967f9bc5e93d41793219110ca411aca1e183d72 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Fri, 19 Sep 2025 09:19:09 +0200 Subject: [PATCH 02/21] fix(database): use SQLAlchemy database to fit new version of OGW-Microservice --- src/opengeodeweb_back/app_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengeodeweb_back/app_config.py b/src/opengeodeweb_back/app_config.py index 96e69745..5725359f 100644 --- a/src/opengeodeweb_back/app_config.py +++ b/src/opengeodeweb_back/app_config.py @@ -5,7 +5,7 @@ # Third party imports # Local application imports -DATABASE_FILENAME = "project.db" # Should be declared only once. +DATABASE_FILENAME = "project.db" class Config(object): From d324cba125d7c48158499e13c4d6ea8f31335af3 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Tue, 30 Sep 2025 16:02:56 +0200 Subject: [PATCH 03/21] removed debug logs, moved SQLAlchemy variables to Vease Back. --- app.py | 30 ++++++++++++++---------- src/opengeodeweb_back/app_config.py | 9 +------ src/opengeodeweb_back/utils_functions.py | 1 - 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/app.py b/app.py index 93d98b74..400d73b6 100644 --- a/app.py +++ b/app.py @@ -29,6 +29,22 @@ ORIGINS = app.config.get("ORIGINS") SSL = app.config.get("SSL") + +def get_db_path_from_config(): + database_uri = app.config.get("SQLALCHEMY_DATABASE_URI", "") + if database_uri.startswith("sqlite:///"): + return database_uri.replace("sqlite:///", "") + return None + + +db_path = get_db_path_from_config() +if db_path: + db_dir = os.path.dirname(db_path) + if db_dir and not os.path.exists(db_dir): + os.makedirs(db_dir, exist_ok=True) + init_database(db_path) + print(f"Database initialized at: {db_path}") + flask_cors.CORS(app, origins=ORIGINS) app.register_blueprint( blueprint_routes.routes, @@ -56,18 +72,8 @@ def return_error(): flask.abort(500, f"Test") -def get_db_path_from_config(): - database_uri = app.config.get("SQLALCHEMY_DATABASE_URI", "") - if database_uri.startswith("sqlite:///"): - return database_uri.replace("sqlite:///", "") - return None - - # ''' Main ''' if __name__ == "__main__": - db_path = get_db_path_from_config() - if db_path: - init_database(db_path) - - print(f"Python is running in {FLASK_DEBUG} mode") + data_folder = app.config.get("DATA_FOLDER_PATH") + upload_folder = app.config.get("UPLOAD_FOLDER") app.run(debug=FLASK_DEBUG, host=DEFAULT_HOST, port=PORT, ssl_context=SSL) diff --git a/src/opengeodeweb_back/app_config.py b/src/opengeodeweb_back/app_config.py index 5725359f..f80e7ca5 100644 --- a/src/opengeodeweb_back/app_config.py +++ b/src/opengeodeweb_back/app_config.py @@ -5,8 +5,6 @@ # Third party imports # Local application imports -DATABASE_FILENAME = "project.db" - class Config(object): FLASK_DEBUG = os.environ.get("FLASK_DEBUG", default=False) @@ -18,6 +16,7 @@ class Config(object): LAST_REQUEST_TIME = time.time() LAST_PING_TIME = time.time() SQLALCHEMY_TRACK_MODIFICATIONS = False + DATABASE_FILENAME = "project.db" class ProdConfig(Config): @@ -26,9 +25,6 @@ class ProdConfig(Config): MINUTES_BEFORE_TIMEOUT = "1" SECONDS_BETWEEN_SHUTDOWNS = "10" DATA_FOLDER_PATH = "/data" - SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.abspath( - os.path.join(DATA_FOLDER_PATH, DATABASE_FILENAME) - )}" class DevConfig(Config): @@ -38,6 +34,3 @@ class DevConfig(Config): SECONDS_BETWEEN_SHUTDOWNS = "10" BASE_DIR = os.path.dirname(os.path.abspath(__file__)) DATA_FOLDER_PATH = os.path.join(BASE_DIR, "data") - SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.join( - BASE_DIR, DATA_FOLDER_PATH, DATABASE_FILENAME - )}" diff --git a/src/opengeodeweb_back/utils_functions.py b/src/opengeodeweb_back/utils_functions.py index 487ad6a9..fb6629e3 100644 --- a/src/opengeodeweb_back/utils_functions.py +++ b/src/opengeodeweb_back/utils_functions.py @@ -87,7 +87,6 @@ def validate_request(request: flask.Request, schema: dict[str, str]) -> None: if json_data is None: json_data = {} - try: validate = fastjsonschema.compile(schema) validate(json_data) From 52947521f736eb054cfc880c4934eaee4f1d439f Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Wed, 1 Oct 2025 09:21:03 +0000 Subject: [PATCH 04/21] Apply prepare changes --- requirements.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index aa902438..5b528e8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --output-file=./requirements.txt --pre ./requirements-internal.in ./requirements.in +# pip-compile --output-file=./requirements.txt --pre ./requirements.in # asgiref==3.*,>=3.9.2 # via flask @@ -10,8 +10,6 @@ blinker==1.*,>=1.9.0 # via flask click==8.*,>=8.3.0 # via flask -fastjsonschema==2.*,>=2.21.1 - # via opengeodeweb-microservice flask[async]==3.0.3 # via # -r requirements.in @@ -21,9 +19,7 @@ flask[async]==3.0.3 flask-cors==6.*,>=6.0.1 # via -r requirements.in flask-sqlalchemy==3.*,>=3.1.1 - # via - # -r requirements.in - # opengeodeweb-microservice + # via -r requirements.in geode-common==33.11.0 # via # -r requirements.in @@ -63,12 +59,8 @@ opengeode-io==7.4.0 # -r requirements.in # geode-viewables # opengeode-geosciencesio -opengeodeweb-microservice==1.*,>=1.0.0 - # via -r requirements-internal.in sqlalchemy==2.*,>=2.0.43 - # via - # flask-sqlalchemy - # opengeodeweb-microservice + # via flask-sqlalchemy typing-extensions==4.*,>=4.15.0 # via sqlalchemy werkzeug==3.0.3 From 5c3d2a5d6060c28a6d78e1e0912e90fc3eea1209 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Wed, 1 Oct 2025 10:20:34 +0000 Subject: [PATCH 05/21] Apply prepare changes --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5b528e8b..fbd6b37c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ blinker==1.*,>=1.9.0 # via flask click==8.*,>=8.3.0 # via flask -flask[async]==3.0.3 +flask[async]==3.*,>=3.0.3 # via # -r requirements.in # flask From 6cc055ee25891de48df8aa42f14488a61b8a896b Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 1 Oct 2025 13:11:19 +0200 Subject: [PATCH 06/21] removed dep : Flask-SQLAlchemy --- requirements.in | 3 +-- src/opengeodeweb_back/app_config.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements.in b/requirements.in index b9c6544f..14d45e01 100644 --- a/requirements.in +++ b/requirements.in @@ -7,5 +7,4 @@ geode-common==33.11.0 geode-viewables==3.3.0 Flask[async]==3.0.3 Flask-Cors==6.0.1 -werkzeug==3.0.3 -Flask-SQLAlchemy==3.1.1 \ No newline at end of file +werkzeug==3.0.3 \ No newline at end of file diff --git a/src/opengeodeweb_back/app_config.py b/src/opengeodeweb_back/app_config.py index f80e7ca5..095b2754 100644 --- a/src/opengeodeweb_back/app_config.py +++ b/src/opengeodeweb_back/app_config.py @@ -15,7 +15,6 @@ class Config(object): REQUEST_COUNTER = 0 LAST_REQUEST_TIME = time.time() LAST_PING_TIME = time.time() - SQLALCHEMY_TRACK_MODIFICATIONS = False DATABASE_FILENAME = "project.db" From eedd720dc5d58f18b7126f0f830d3637ed776e93 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Wed, 1 Oct 2025 11:11:44 +0000 Subject: [PATCH 07/21] Apply prepare changes --- requirements.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index fbd6b37c..3be0d76d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,19 +15,14 @@ flask[async]==3.*,>=3.0.3 # -r requirements.in # flask # flask-cors - # flask-sqlalchemy flask-cors==6.*,>=6.0.1 # via -r requirements.in -flask-sqlalchemy==3.*,>=3.1.1 - # via -r requirements.in geode-common==33.11.0 # via # -r requirements.in # geode-viewables geode-viewables==3.3.0 # via -r requirements.in -greenlet==3.*,>=3.2.4 - # via sqlalchemy itsdangerous==2.*,>=2.2.0 # via flask jinja2==3.*,>=3.1.6 @@ -59,10 +54,6 @@ opengeode-io==7.4.0 # -r requirements.in # geode-viewables # opengeode-geosciencesio -sqlalchemy==2.*,>=2.0.43 - # via flask-sqlalchemy -typing-extensions==4.*,>=4.15.0 - # via sqlalchemy werkzeug==3.0.3 # via # -r requirements.in From d0d5324e429641242b27d29ced2f950c6df4b66d Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:05:00 +0000 Subject: [PATCH 08/21] Apply prepare changes --- requirements.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index c9b18da1..d32a13d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,16 +6,16 @@ # asgiref~=3.0 # via flask -blinker==1.*,>=1.9.0 +blinker~=1.0 # via flask -click==8.*,>=8.3.0 +click~=8.0 # via flask -flask[async]==3.*,>=3.0.3 +flask[async]~=3.0 # via # -r requirements.in # flask # flask-cors -flask-cors==6.*,>=6.0.1 +flask-cors~=6.0 # via -r requirements.in geode-common==33.11.0 # via @@ -23,14 +23,13 @@ geode-common==33.11.0 # geode-viewables geode-viewables==3.3.0 # via -r requirements.in -itsdangerous==2.*,>=2.2.0 +itsdangerous~=2.0 # via flask -jinja2==3.*,>=3.1.6 +jinja2~=3.0 # via flask -markupsafe==3.*,>=3.0.3 +markupsafe~=3.0 # via # jinja2 - # opengeodeweb-microservice # werkzeug opengeode-core==15.27.4 # via @@ -60,4 +59,3 @@ werkzeug==3.0.3 # -r requirements.in # flask # flask-cors - # opengeodeweb-microservice From 1ca693b6beab208e1d4be8b07be167ae1ff848cf Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Fri, 3 Oct 2025 16:11:17 +0200 Subject: [PATCH 09/21] refacto app.py & conftest --- app.py | 79 ------------------ src/opengeodeweb_back/app.py | 151 +++++++++++++++++++++++++++++++++++ tests/conftest.py | 26 ++++-- 3 files changed, 171 insertions(+), 85 deletions(-) delete mode 100644 app.py create mode 100644 src/opengeodeweb_back/app.py diff --git a/app.py b/app.py deleted file mode 100644 index 400d73b6..00000000 --- a/app.py +++ /dev/null @@ -1,79 +0,0 @@ -"""Packages""" - -import os - -import flask -import flask_cors -from werkzeug.exceptions import HTTPException - -from src.opengeodeweb_back.routes import blueprint_routes -from src.opengeodeweb_back.routes.models import blueprint_models -from src.opengeodeweb_back.utils_functions import handle_exception -from src.opengeodeweb_back import app_config -from opengeodeweb_microservice.database.connection import init_database - - -""" Global config """ -app = flask.Flask(__name__) - -""" Config variables """ -FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False - -if FLASK_DEBUG == False: - app.config.from_object(app_config.ProdConfig) -else: - app.config.from_object(app_config.DevConfig) - -DEFAULT_HOST = app.config.get("DEFAULT_HOST") -PORT = int(app.config.get("DEFAULT_PORT")) -ORIGINS = app.config.get("ORIGINS") -SSL = app.config.get("SSL") - - -def get_db_path_from_config(): - database_uri = app.config.get("SQLALCHEMY_DATABASE_URI", "") - if database_uri.startswith("sqlite:///"): - return database_uri.replace("sqlite:///", "") - return None - - -db_path = get_db_path_from_config() -if db_path: - db_dir = os.path.dirname(db_path) - if db_dir and not os.path.exists(db_dir): - os.makedirs(db_dir, exist_ok=True) - init_database(db_path) - print(f"Database initialized at: {db_path}") - -flask_cors.CORS(app, origins=ORIGINS) -app.register_blueprint( - blueprint_routes.routes, - url_prefix="/", - name="blueprint_routes", -) - -app.register_blueprint( - blueprint_models.routes, - url_prefix="/models", - name="blueprint_models", -) - - -@app.errorhandler(HTTPException) -def errorhandler(e): - return handle_exception(e) - - -@app.route( - "/error", - methods=["POST"], -) -def return_error(): - flask.abort(500, f"Test") - - -# ''' Main ''' -if __name__ == "__main__": - data_folder = app.config.get("DATA_FOLDER_PATH") - upload_folder = app.config.get("UPLOAD_FOLDER") - app.run(debug=FLASK_DEBUG, host=DEFAULT_HOST, port=PORT, ssl_context=SSL) diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py new file mode 100644 index 00000000..60770ebe --- /dev/null +++ b/src/opengeodeweb_back/app.py @@ -0,0 +1,151 @@ +"""Packages""" + +import argparse +import os +import time + +import flask +import flask_cors +from flask_cors import cross_origin +from werkzeug.exceptions import HTTPException + +from src.opengeodeweb_back import utils_functions, app_config +from src.opengeodeweb_back.routes import blueprint_routes +from src.opengeodeweb_back.routes.models import blueprint_models +from opengeodeweb_microservice.database.connection import init_database + + +""" Global config """ +app = flask.Flask(__name__) + +""" Config variables """ +FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False + +if FLASK_DEBUG == False: + app.config.from_object(app_config.ProdConfig) +else: + app.config.from_object(app_config.DevConfig) + +DEFAULT_HOST = app.config.get("DEFAULT_HOST") +DEFAULT_PORT = int(app.config.get("DEFAULT_PORT")) +DEFAULT_DATA_FOLDER_PATH = app.config.get("DEFAULT_DATA_FOLDER_PATH") +ORIGINS = app.config.get("ORIGINS") +TIMEOUT = int(app.config.get("MINUTES_BEFORE_TIMEOUT")) +SSL = app.config.get("SSL") +SECONDS_BETWEEN_SHUTDOWNS = float(app.config.get("SECONDS_BETWEEN_SHUTDOWNS")) + + +def get_db_path_from_config(): + database_uri = f"{os.path.abspath( + os.path.join(app.config.get('DATA_FOLDER_PATH'), app.config.get('DATABASE_FILENAME')) + )}" + return database_uri + + +app.register_blueprint( + blueprint_routes.routes, + url_prefix="/opengeodeweb_back", + name="opengeodeweb_back", +) + +app.register_blueprint( + blueprint_models.routes, + url_prefix="/opengeodeweb_back/models", + name="opengeodeweb_models", +) + +if FLASK_DEBUG == False: + utils_functions.set_interval( + utils_functions.kill_task, SECONDS_BETWEEN_SHUTDOWNS, app + ) + + +@app.errorhandler(HTTPException) +def errorhandler(e): + return utils_functions.handle_exception(e) + + +@app.route("/", methods=["POST"]) +@cross_origin() +def root(): + return flask.make_response({}, 200) + + +@app.route("/kill", methods=["POST"]) +@cross_origin() +def kill() -> None: + print("Manual server kill, shutting down...", flush=True) + os._exit(0) + + +def run_server(): + parser = argparse.ArgumentParser( + prog="OpenGeodeWeb-Back", description="Backend server for OpenGeodeWeb" + ) + parser.add_argument("--host", type=str, default=DEFAULT_HOST, help="Host to run on") + parser.add_argument( + "-p", "--port", type=int, default=DEFAULT_PORT, help="Port to listen on" + ) + parser.add_argument( + "-d", + "--debug", + default=FLASK_DEBUG, + help="Whether to run in debug mode", + action="store_true", + ) + parser.add_argument( + "-dfp", + "--data_folder_path", + type=str, + default=DEFAULT_DATA_FOLDER_PATH, + help="Path to the folder where data is stored", + ) + parser.add_argument( + "-ufp", + "--upload_folder_path", + type=str, + default=DEFAULT_DATA_FOLDER_PATH, + help="Path to the folder where uploads are stored", + ) + parser.add_argument( + "-origins", + "--allowed_origins", + default=ORIGINS, + help="Origins that are allowed to connect to the server", + ) + parser.add_argument( + "-t", + "--timeout", + default=TIMEOUT, + help="Number of minutes before the server times out", + ) + args = parser.parse_args() + + app.config.update(DATA_FOLDER_PATH=args.data_folder_path) + app.config.update(UPLOAD_FOLDER=args.upload_folder_path) + app.config.update(MINUTES_BEFORE_TIMEOUT=args.timeout) + + flask_cors.CORS(app, origins=args.allowed_origins) + + print( + f"Host: {args.host}, Port: {args.port}, Debug: {args.debug}, " + f"Data folder path: {args.data_folder_path}, Timeout: {args.timeout}, " + f"Origins: {args.allowed_origins}", + flush=True, + ) + + db_path = get_db_path_from_config() + print("db_path", db_path, flush=True) + if db_path: + db_dir = os.path.dirname(db_path) + if db_dir and not os.path.exists(db_dir): + os.makedirs(db_dir, exist_ok=True) + init_database(db_path) + print(f"Database initialized at: {db_path}") + + app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL) + + +# ''' Main ''' +if __name__ == "__main__": + run_server() diff --git a/tests/conftest.py b/tests/conftest.py index 2b4f9cc3..b4f133dc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,34 +1,48 @@ # Standard library imports import time import shutil +import os +from pathlib import Path +from typing import Generator # Third party imports -import os import pytest # Local application imports -from app import app +from src.opengeodeweb_back.app import app +from src.opengeodeweb_back import app_config from opengeodeweb_microservice.database.connection import init_database TEST_ID = "1" @pytest.fixture(scope="session", autouse=True) -def copy_data(): +def configure_test_environment() -> Generator[None, None, None]: + base_path = Path(__file__).parent + test_data_path = base_path / "data" + shutil.rmtree("./data", ignore_errors=True) - shutil.copytree("./tests/data/", f"./data/{TEST_ID}/", dirs_exist_ok=True) + shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) + app.config["TESTING"] = True app.config["SERVER_NAME"] = "TEST" app.config["DATA_FOLDER_PATH"] = "./data/" app.config["UPLOAD_FOLDER"] = "./tests/data/" - BASE_DIR = os.path.abspath(os.path.dirname(__file__)) - db_path = os.path.join(BASE_DIR, "data", "project.db") + + db_path = os.path.join(base_path, "data", "project.db") app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}" print("Current working directory:", os.getcwd()) print("Directory contents:", os.listdir(".")) init_database(db_path) + os.environ["TEST_DB_PATH"] = str(db_path) + + yield + tmp_data_path = app.config.get("DATA_FOLDER_PATH") + if tmp_data_path and os.path.exists(tmp_data_path): + shutil.rmtree(tmp_data_path, ignore_errors=True) + print(f"Cleaned up test data folder: {tmp_data_path}", flush=True) @pytest.fixture From e20995e1db324dfcf46004f671b4d61800563843 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Fri, 3 Oct 2025 16:41:59 +0200 Subject: [PATCH 10/21] moving tests folder into src folder --- pyproject.toml | 4 +- requirements-internal.txt | 54 ++++++++++++++++++ src/opengeodeweb_back/app.py | 6 +- {tests => src/tests}/__init__.py | 0 {tests => src/tests}/conftest.py | 10 +++- {tests => src/tests}/data/corbi.og_brep | Bin {tests => src/tests}/data/cube.og_brep | Bin {tests => src/tests}/data/cube.vtm | 0 {tests => src/tests}/data/hat.vtp | 0 .../tests}/data/polygon_attribute.vtp | 0 .../tests}/data/polyhedron_attribute.vtu | 0 {tests => src/tests}/data/test.bmp | Bin {tests => src/tests}/data/test.dat | 0 {tests => src/tests}/data/test.dem | 0 {tests => src/tests}/data/test.dev | 0 {tests => src/tests}/data/test.dxf | 0 {tests => src/tests}/data/test.grdecl | 0 {tests => src/tests}/data/test.jpg | Bin {tests => src/tests}/data/test.lso | 0 {tests => src/tests}/data/test.ml | 0 {tests => src/tests}/data/test.msh | 0 {tests => src/tests}/data/test.obj | 0 {tests => src/tests}/data/test.og_brep | Bin {tests => src/tests}/data/test.og_edc2d | Bin {tests => src/tests}/data/test.og_edc3d | Bin {tests => src/tests}/data/test.og_grp | Bin {tests => src/tests}/data/test.og_hso3d | Bin {tests => src/tests}/data/test.og_img2d | Bin {tests => src/tests}/data/test.og_img3d | Bin {tests => src/tests}/data/test.og_istrm | Bin {tests => src/tests}/data/test.og_ixsctn | Bin {tests => src/tests}/data/test.og_lrgd2d | Bin {tests => src/tests}/data/test.og_lrgd3d | Bin {tests => src/tests}/data/test.og_psf2d | Bin {tests => src/tests}/data/test.og_psf3d | Bin {tests => src/tests}/data/test.og_pso3d | Bin {tests => src/tests}/data/test.og_pts2d | Bin {tests => src/tests}/data/test.og_pts3d | Bin {tests => src/tests}/data/test.og_rgd2d | Bin {tests => src/tests}/data/test.og_rgd3d | Bin {tests => src/tests}/data/test.og_sctn | Bin {tests => src/tests}/data/test.og_strm | Bin {tests => src/tests}/data/test.og_tsf2d | Bin {tests => src/tests}/data/test.og_tsf3d | Bin {tests => src/tests}/data/test.og_tso3d | Bin {tests => src/tests}/data/test.og_vts | Bin {tests => src/tests}/data/test.og_xsctn | Bin {tests => src/tests}/data/test.pl | 0 {tests => src/tests}/data/test.ply | 0 {tests => src/tests}/data/test.png | Bin {tests => src/tests}/data/test.shp | Bin {tests => src/tests}/data/test.shx | Bin {tests => src/tests}/data/test.shz | Bin {tests => src/tests}/data/test.smesh | 0 {tests => src/tests}/data/test.stl | 0 {tests => src/tests}/data/test.svg | 0 {tests => src/tests}/data/test.tif | Bin {tests => src/tests}/data/test.tiff | Bin {tests => src/tests}/data/test.ts | 0 {tests => src/tests}/data/test.txt | 0 {tests => src/tests}/data/test.vo | 0 {tests => src/tests}/data/test.vs | 0 {tests => src/tests}/data/test.vti | 0 {tests => src/tests}/data/test.vtp | 0 {tests => src/tests}/data/test.vtu | 0 {tests => src/tests}/data/test.wl | 0 {tests => src/tests}/data/test__ascii@@ | 0 .../tests}/data/vertex_attribute.vtp | 0 {tests => src/tests}/test_geode_functions.py | 0 {tests => src/tests}/test_models_routes.py | 0 {tests => src/tests}/test_routes.py | 0 {tests => src/tests}/test_utils_functions.py | 0 72 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 requirements-internal.txt rename {tests => src/tests}/__init__.py (100%) rename {tests => src/tests}/conftest.py (89%) rename {tests => src/tests}/data/corbi.og_brep (100%) rename {tests => src/tests}/data/cube.og_brep (100%) rename {tests => src/tests}/data/cube.vtm (100%) rename {tests => src/tests}/data/hat.vtp (100%) rename {tests => src/tests}/data/polygon_attribute.vtp (100%) rename {tests => src/tests}/data/polyhedron_attribute.vtu (100%) rename {tests => src/tests}/data/test.bmp (100%) rename {tests => src/tests}/data/test.dat (100%) rename {tests => src/tests}/data/test.dem (100%) rename {tests => src/tests}/data/test.dev (100%) rename {tests => src/tests}/data/test.dxf (100%) rename {tests => src/tests}/data/test.grdecl (100%) rename {tests => src/tests}/data/test.jpg (100%) rename {tests => src/tests}/data/test.lso (100%) rename {tests => src/tests}/data/test.ml (100%) rename {tests => src/tests}/data/test.msh (100%) rename {tests => src/tests}/data/test.obj (100%) rename {tests => src/tests}/data/test.og_brep (100%) rename {tests => src/tests}/data/test.og_edc2d (100%) rename {tests => src/tests}/data/test.og_edc3d (100%) rename {tests => src/tests}/data/test.og_grp (100%) rename {tests => src/tests}/data/test.og_hso3d (100%) rename {tests => src/tests}/data/test.og_img2d (100%) rename {tests => src/tests}/data/test.og_img3d (100%) rename {tests => src/tests}/data/test.og_istrm (100%) rename {tests => src/tests}/data/test.og_ixsctn (100%) rename {tests => src/tests}/data/test.og_lrgd2d (100%) rename {tests => src/tests}/data/test.og_lrgd3d (100%) rename {tests => src/tests}/data/test.og_psf2d (100%) rename {tests => src/tests}/data/test.og_psf3d (100%) rename {tests => src/tests}/data/test.og_pso3d (100%) rename {tests => src/tests}/data/test.og_pts2d (100%) rename {tests => src/tests}/data/test.og_pts3d (100%) rename {tests => src/tests}/data/test.og_rgd2d (100%) rename {tests => src/tests}/data/test.og_rgd3d (100%) rename {tests => src/tests}/data/test.og_sctn (100%) rename {tests => src/tests}/data/test.og_strm (100%) rename {tests => src/tests}/data/test.og_tsf2d (100%) rename {tests => src/tests}/data/test.og_tsf3d (100%) rename {tests => src/tests}/data/test.og_tso3d (100%) rename {tests => src/tests}/data/test.og_vts (100%) rename {tests => src/tests}/data/test.og_xsctn (100%) rename {tests => src/tests}/data/test.pl (100%) rename {tests => src/tests}/data/test.ply (100%) rename {tests => src/tests}/data/test.png (100%) rename {tests => src/tests}/data/test.shp (100%) rename {tests => src/tests}/data/test.shx (100%) rename {tests => src/tests}/data/test.shz (100%) rename {tests => src/tests}/data/test.smesh (100%) rename {tests => src/tests}/data/test.stl (100%) rename {tests => src/tests}/data/test.svg (100%) rename {tests => src/tests}/data/test.tif (100%) rename {tests => src/tests}/data/test.tiff (100%) rename {tests => src/tests}/data/test.ts (100%) rename {tests => src/tests}/data/test.txt (100%) rename {tests => src/tests}/data/test.vo (100%) rename {tests => src/tests}/data/test.vs (100%) rename {tests => src/tests}/data/test.vti (100%) rename {tests => src/tests}/data/test.vtp (100%) rename {tests => src/tests}/data/test.vtu (100%) rename {tests => src/tests}/data/test.wl (100%) rename {tests => src/tests}/data/test__ascii@@ (100%) rename {tests => src/tests}/data/vertex_attribute.vtp (100%) rename {tests => src/tests}/test_geode_functions.py (100%) rename {tests => src/tests}/test_models_routes.py (100%) rename {tests => src/tests}/test_routes.py (100%) rename {tests => src/tests}/test_utils_functions.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 1a5e40b9..929bb921 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,6 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" - [project] name = "OpenGeodeWeb-Back" version = "0.0.0" @@ -21,6 +20,9 @@ classifiers = [ "Homepage" = "https://github.com/Geode-solutions/OpenGeodeWeb-Back" "Bug Tracker" = "https://github.com/Geode-solutions/OpenGeodeWeb-Back/issues" +[project.scripts] +opengeodeweb-back = "opengeodeweb_back.app:run_server" + [tool.setuptools.dynamic] dependencies = { file = ["requirements.txt"] } diff --git a/requirements-internal.txt b/requirements-internal.txt new file mode 100644 index 00000000..b09b49d8 --- /dev/null +++ b/requirements-internal.txt @@ -0,0 +1,54 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile requirements-internal.in +# +blinker==1.9.0 + # via + # flask + # opengeodeweb-microservice +click==8.3.0 + # via + # flask + # opengeodeweb-microservice +fastjsonschema==2.21.1 + # via opengeodeweb-microservice +flask==3.1.2 + # via + # flask-sqlalchemy + # opengeodeweb-microservice +flask-sqlalchemy==3.1.1 + # via opengeodeweb-microservice +greenlet==3.2.4 + # via + # opengeodeweb-microservice + # sqlalchemy +itsdangerous==2.2.0 + # via + # flask + # opengeodeweb-microservice +jinja2==3.1.6 + # via + # flask + # opengeodeweb-microservice +markupsafe==3.0.3 + # via + # flask + # jinja2 + # opengeodeweb-microservice + # werkzeug +opengeodeweb-microservice==1.0.3 + # via -r requirements-internal.in +sqlalchemy==2.0.43 + # via + # flask-sqlalchemy + # opengeodeweb-microservice +typing-extensions==4.15.0 + # via + # opengeodeweb-microservice + # sqlalchemy +werkzeug==3.1.3 + # via + # flask + # opengeodeweb-microservice diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index 60770ebe..3aa4ceb6 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -9,9 +9,9 @@ from flask_cors import cross_origin from werkzeug.exceptions import HTTPException -from src.opengeodeweb_back import utils_functions, app_config -from src.opengeodeweb_back.routes import blueprint_routes -from src.opengeodeweb_back.routes.models import blueprint_models +from opengeodeweb_back import utils_functions, app_config +from opengeodeweb_back.routes import blueprint_routes +from opengeodeweb_back.routes.models import blueprint_models from opengeodeweb_microservice.database.connection import init_database diff --git a/tests/__init__.py b/src/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to src/tests/__init__.py diff --git a/tests/conftest.py b/src/tests/conftest.py similarity index 89% rename from tests/conftest.py rename to src/tests/conftest.py index b4f133dc..48cdbb22 100644 --- a/tests/conftest.py +++ b/src/tests/conftest.py @@ -9,8 +9,9 @@ import pytest # Local application imports -from src.opengeodeweb_back.app import app -from src.opengeodeweb_back import app_config +from opengeodeweb_back.app import app + +# from opengeodeweb_back import app_config from opengeodeweb_microservice.database.connection import init_database TEST_ID = "1" @@ -21,14 +22,17 @@ def configure_test_environment() -> Generator[None, None, None]: base_path = Path(__file__).parent test_data_path = base_path / "data" + # Clean up any existing test data shutil.rmtree("./data", ignore_errors=True) shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) + # Configure app for testing app.config["TESTING"] = True app.config["SERVER_NAME"] = "TEST" app.config["DATA_FOLDER_PATH"] = "./data/" app.config["UPLOAD_FOLDER"] = "./tests/data/" + # Setup database db_path = os.path.join(base_path, "data", "project.db") app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}" @@ -39,6 +43,8 @@ def configure_test_environment() -> Generator[None, None, None]: os.environ["TEST_DB_PATH"] = str(db_path) yield + + # Cleanup after tests tmp_data_path = app.config.get("DATA_FOLDER_PATH") if tmp_data_path and os.path.exists(tmp_data_path): shutil.rmtree(tmp_data_path, ignore_errors=True) diff --git a/tests/data/corbi.og_brep b/src/tests/data/corbi.og_brep similarity index 100% rename from tests/data/corbi.og_brep rename to src/tests/data/corbi.og_brep diff --git a/tests/data/cube.og_brep b/src/tests/data/cube.og_brep similarity index 100% rename from tests/data/cube.og_brep rename to src/tests/data/cube.og_brep diff --git a/tests/data/cube.vtm b/src/tests/data/cube.vtm similarity index 100% rename from tests/data/cube.vtm rename to src/tests/data/cube.vtm diff --git a/tests/data/hat.vtp b/src/tests/data/hat.vtp similarity index 100% rename from tests/data/hat.vtp rename to src/tests/data/hat.vtp diff --git a/tests/data/polygon_attribute.vtp b/src/tests/data/polygon_attribute.vtp similarity index 100% rename from tests/data/polygon_attribute.vtp rename to src/tests/data/polygon_attribute.vtp diff --git a/tests/data/polyhedron_attribute.vtu b/src/tests/data/polyhedron_attribute.vtu similarity index 100% rename from tests/data/polyhedron_attribute.vtu rename to src/tests/data/polyhedron_attribute.vtu diff --git a/tests/data/test.bmp b/src/tests/data/test.bmp similarity index 100% rename from tests/data/test.bmp rename to src/tests/data/test.bmp diff --git a/tests/data/test.dat b/src/tests/data/test.dat similarity index 100% rename from tests/data/test.dat rename to src/tests/data/test.dat diff --git a/tests/data/test.dem b/src/tests/data/test.dem similarity index 100% rename from tests/data/test.dem rename to src/tests/data/test.dem diff --git a/tests/data/test.dev b/src/tests/data/test.dev similarity index 100% rename from tests/data/test.dev rename to src/tests/data/test.dev diff --git a/tests/data/test.dxf b/src/tests/data/test.dxf similarity index 100% rename from tests/data/test.dxf rename to src/tests/data/test.dxf diff --git a/tests/data/test.grdecl b/src/tests/data/test.grdecl similarity index 100% rename from tests/data/test.grdecl rename to src/tests/data/test.grdecl diff --git a/tests/data/test.jpg b/src/tests/data/test.jpg similarity index 100% rename from tests/data/test.jpg rename to src/tests/data/test.jpg diff --git a/tests/data/test.lso b/src/tests/data/test.lso similarity index 100% rename from tests/data/test.lso rename to src/tests/data/test.lso diff --git a/tests/data/test.ml b/src/tests/data/test.ml similarity index 100% rename from tests/data/test.ml rename to src/tests/data/test.ml diff --git a/tests/data/test.msh b/src/tests/data/test.msh similarity index 100% rename from tests/data/test.msh rename to src/tests/data/test.msh diff --git a/tests/data/test.obj b/src/tests/data/test.obj similarity index 100% rename from tests/data/test.obj rename to src/tests/data/test.obj diff --git a/tests/data/test.og_brep b/src/tests/data/test.og_brep similarity index 100% rename from tests/data/test.og_brep rename to src/tests/data/test.og_brep diff --git a/tests/data/test.og_edc2d b/src/tests/data/test.og_edc2d similarity index 100% rename from tests/data/test.og_edc2d rename to src/tests/data/test.og_edc2d diff --git a/tests/data/test.og_edc3d b/src/tests/data/test.og_edc3d similarity index 100% rename from tests/data/test.og_edc3d rename to src/tests/data/test.og_edc3d diff --git a/tests/data/test.og_grp b/src/tests/data/test.og_grp similarity index 100% rename from tests/data/test.og_grp rename to src/tests/data/test.og_grp diff --git a/tests/data/test.og_hso3d b/src/tests/data/test.og_hso3d similarity index 100% rename from tests/data/test.og_hso3d rename to src/tests/data/test.og_hso3d diff --git a/tests/data/test.og_img2d b/src/tests/data/test.og_img2d similarity index 100% rename from tests/data/test.og_img2d rename to src/tests/data/test.og_img2d diff --git a/tests/data/test.og_img3d b/src/tests/data/test.og_img3d similarity index 100% rename from tests/data/test.og_img3d rename to src/tests/data/test.og_img3d diff --git a/tests/data/test.og_istrm b/src/tests/data/test.og_istrm similarity index 100% rename from tests/data/test.og_istrm rename to src/tests/data/test.og_istrm diff --git a/tests/data/test.og_ixsctn b/src/tests/data/test.og_ixsctn similarity index 100% rename from tests/data/test.og_ixsctn rename to src/tests/data/test.og_ixsctn diff --git a/tests/data/test.og_lrgd2d b/src/tests/data/test.og_lrgd2d similarity index 100% rename from tests/data/test.og_lrgd2d rename to src/tests/data/test.og_lrgd2d diff --git a/tests/data/test.og_lrgd3d b/src/tests/data/test.og_lrgd3d similarity index 100% rename from tests/data/test.og_lrgd3d rename to src/tests/data/test.og_lrgd3d diff --git a/tests/data/test.og_psf2d b/src/tests/data/test.og_psf2d similarity index 100% rename from tests/data/test.og_psf2d rename to src/tests/data/test.og_psf2d diff --git a/tests/data/test.og_psf3d b/src/tests/data/test.og_psf3d similarity index 100% rename from tests/data/test.og_psf3d rename to src/tests/data/test.og_psf3d diff --git a/tests/data/test.og_pso3d b/src/tests/data/test.og_pso3d similarity index 100% rename from tests/data/test.og_pso3d rename to src/tests/data/test.og_pso3d diff --git a/tests/data/test.og_pts2d b/src/tests/data/test.og_pts2d similarity index 100% rename from tests/data/test.og_pts2d rename to src/tests/data/test.og_pts2d diff --git a/tests/data/test.og_pts3d b/src/tests/data/test.og_pts3d similarity index 100% rename from tests/data/test.og_pts3d rename to src/tests/data/test.og_pts3d diff --git a/tests/data/test.og_rgd2d b/src/tests/data/test.og_rgd2d similarity index 100% rename from tests/data/test.og_rgd2d rename to src/tests/data/test.og_rgd2d diff --git a/tests/data/test.og_rgd3d b/src/tests/data/test.og_rgd3d similarity index 100% rename from tests/data/test.og_rgd3d rename to src/tests/data/test.og_rgd3d diff --git a/tests/data/test.og_sctn b/src/tests/data/test.og_sctn similarity index 100% rename from tests/data/test.og_sctn rename to src/tests/data/test.og_sctn diff --git a/tests/data/test.og_strm b/src/tests/data/test.og_strm similarity index 100% rename from tests/data/test.og_strm rename to src/tests/data/test.og_strm diff --git a/tests/data/test.og_tsf2d b/src/tests/data/test.og_tsf2d similarity index 100% rename from tests/data/test.og_tsf2d rename to src/tests/data/test.og_tsf2d diff --git a/tests/data/test.og_tsf3d b/src/tests/data/test.og_tsf3d similarity index 100% rename from tests/data/test.og_tsf3d rename to src/tests/data/test.og_tsf3d diff --git a/tests/data/test.og_tso3d b/src/tests/data/test.og_tso3d similarity index 100% rename from tests/data/test.og_tso3d rename to src/tests/data/test.og_tso3d diff --git a/tests/data/test.og_vts b/src/tests/data/test.og_vts similarity index 100% rename from tests/data/test.og_vts rename to src/tests/data/test.og_vts diff --git a/tests/data/test.og_xsctn b/src/tests/data/test.og_xsctn similarity index 100% rename from tests/data/test.og_xsctn rename to src/tests/data/test.og_xsctn diff --git a/tests/data/test.pl b/src/tests/data/test.pl similarity index 100% rename from tests/data/test.pl rename to src/tests/data/test.pl diff --git a/tests/data/test.ply b/src/tests/data/test.ply similarity index 100% rename from tests/data/test.ply rename to src/tests/data/test.ply diff --git a/tests/data/test.png b/src/tests/data/test.png similarity index 100% rename from tests/data/test.png rename to src/tests/data/test.png diff --git a/tests/data/test.shp b/src/tests/data/test.shp similarity index 100% rename from tests/data/test.shp rename to src/tests/data/test.shp diff --git a/tests/data/test.shx b/src/tests/data/test.shx similarity index 100% rename from tests/data/test.shx rename to src/tests/data/test.shx diff --git a/tests/data/test.shz b/src/tests/data/test.shz similarity index 100% rename from tests/data/test.shz rename to src/tests/data/test.shz diff --git a/tests/data/test.smesh b/src/tests/data/test.smesh similarity index 100% rename from tests/data/test.smesh rename to src/tests/data/test.smesh diff --git a/tests/data/test.stl b/src/tests/data/test.stl similarity index 100% rename from tests/data/test.stl rename to src/tests/data/test.stl diff --git a/tests/data/test.svg b/src/tests/data/test.svg similarity index 100% rename from tests/data/test.svg rename to src/tests/data/test.svg diff --git a/tests/data/test.tif b/src/tests/data/test.tif similarity index 100% rename from tests/data/test.tif rename to src/tests/data/test.tif diff --git a/tests/data/test.tiff b/src/tests/data/test.tiff similarity index 100% rename from tests/data/test.tiff rename to src/tests/data/test.tiff diff --git a/tests/data/test.ts b/src/tests/data/test.ts similarity index 100% rename from tests/data/test.ts rename to src/tests/data/test.ts diff --git a/tests/data/test.txt b/src/tests/data/test.txt similarity index 100% rename from tests/data/test.txt rename to src/tests/data/test.txt diff --git a/tests/data/test.vo b/src/tests/data/test.vo similarity index 100% rename from tests/data/test.vo rename to src/tests/data/test.vo diff --git a/tests/data/test.vs b/src/tests/data/test.vs similarity index 100% rename from tests/data/test.vs rename to src/tests/data/test.vs diff --git a/tests/data/test.vti b/src/tests/data/test.vti similarity index 100% rename from tests/data/test.vti rename to src/tests/data/test.vti diff --git a/tests/data/test.vtp b/src/tests/data/test.vtp similarity index 100% rename from tests/data/test.vtp rename to src/tests/data/test.vtp diff --git a/tests/data/test.vtu b/src/tests/data/test.vtu similarity index 100% rename from tests/data/test.vtu rename to src/tests/data/test.vtu diff --git a/tests/data/test.wl b/src/tests/data/test.wl similarity index 100% rename from tests/data/test.wl rename to src/tests/data/test.wl diff --git a/tests/data/test__ascii@@ b/src/tests/data/test__ascii@@ similarity index 100% rename from tests/data/test__ascii@@ rename to src/tests/data/test__ascii@@ diff --git a/tests/data/vertex_attribute.vtp b/src/tests/data/vertex_attribute.vtp similarity index 100% rename from tests/data/vertex_attribute.vtp rename to src/tests/data/vertex_attribute.vtp diff --git a/tests/test_geode_functions.py b/src/tests/test_geode_functions.py similarity index 100% rename from tests/test_geode_functions.py rename to src/tests/test_geode_functions.py diff --git a/tests/test_models_routes.py b/src/tests/test_models_routes.py similarity index 100% rename from tests/test_models_routes.py rename to src/tests/test_models_routes.py diff --git a/tests/test_routes.py b/src/tests/test_routes.py similarity index 100% rename from tests/test_routes.py rename to src/tests/test_routes.py diff --git a/tests/test_utils_functions.py b/src/tests/test_utils_functions.py similarity index 100% rename from tests/test_utils_functions.py rename to src/tests/test_utils_functions.py From 582c05c680addbe596c05245023ff814b81ca7a8 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Fri, 3 Oct 2025 16:58:36 +0200 Subject: [PATCH 11/21] requirements --- requirements-internal.txt | 54 ----------------------- requirements.txt | 92 ++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 103 deletions(-) delete mode 100644 requirements-internal.txt diff --git a/requirements-internal.txt b/requirements-internal.txt deleted file mode 100644 index b09b49d8..00000000 --- a/requirements-internal.txt +++ /dev/null @@ -1,54 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile requirements-internal.in -# -blinker==1.9.0 - # via - # flask - # opengeodeweb-microservice -click==8.3.0 - # via - # flask - # opengeodeweb-microservice -fastjsonschema==2.21.1 - # via opengeodeweb-microservice -flask==3.1.2 - # via - # flask-sqlalchemy - # opengeodeweb-microservice -flask-sqlalchemy==3.1.1 - # via opengeodeweb-microservice -greenlet==3.2.4 - # via - # opengeodeweb-microservice - # sqlalchemy -itsdangerous==2.2.0 - # via - # flask - # opengeodeweb-microservice -jinja2==3.1.6 - # via - # flask - # opengeodeweb-microservice -markupsafe==3.0.3 - # via - # flask - # jinja2 - # opengeodeweb-microservice - # werkzeug -opengeodeweb-microservice==1.0.3 - # via -r requirements-internal.in -sqlalchemy==2.0.43 - # via - # flask-sqlalchemy - # opengeodeweb-microservice -typing-extensions==4.15.0 - # via - # opengeodeweb-microservice - # sqlalchemy -werkzeug==3.1.3 - # via - # flask - # opengeodeweb-microservice diff --git a/requirements.txt b/requirements.txt index aab1fae1..b09b49d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,59 +2,53 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --output-file=./requirements.txt --pre ./requirements.in +# pip-compile requirements-internal.in # -asgiref~=3.9 - # via flask -blinker~=1.0 - # via flask -click~=8.0 - # via flask -flask[async]~=3.0 - # via - # -r requirements.in - # flask-cors -flask-cors~=6.0 - # via -r requirements.in -geode-common==33.11.0 - # via - # -r requirements.in - # geode-viewables -geode-viewables==3.3.0 - # via -r requirements.in -itsdangerous~=2.0 - # via flask -jinja2~=3.0 - # via flask -markupsafe~=3.0 +blinker==1.9.0 + # via + # flask + # opengeodeweb-microservice +click==8.3.0 + # via + # flask + # opengeodeweb-microservice +fastjsonschema==2.21.1 + # via opengeodeweb-microservice +flask==3.1.2 + # via + # flask-sqlalchemy + # opengeodeweb-microservice +flask-sqlalchemy==3.1.1 + # via opengeodeweb-microservice +greenlet==3.2.4 + # via + # opengeodeweb-microservice + # sqlalchemy +itsdangerous==2.2.0 + # via + # flask + # opengeodeweb-microservice +jinja2==3.1.6 + # via + # flask + # opengeodeweb-microservice +markupsafe==3.0.3 # via # flask # jinja2 + # opengeodeweb-microservice # werkzeug -opengeode-core==15.27.4 - # via - # -r requirements.in - # geode-common - # geode-viewables - # opengeode-geosciences - # opengeode-geosciencesio - # opengeode-inspector - # opengeode-io -opengeode-geosciences==9.4.1 - # via - # -r requirements.in - # geode-viewables - # opengeode-geosciencesio -opengeode-geosciencesio==5.8.0 - # via -r requirements.in -opengeode-inspector==6.8.1 - # via -r requirements.in -opengeode-io==7.4.0 - # via - # -r requirements.in - # geode-viewables - # opengeode-geosciencesio -werkzeug==3.0.3 +opengeodeweb-microservice==1.0.3 + # via -r requirements-internal.in +sqlalchemy==2.0.43 + # via + # flask-sqlalchemy + # opengeodeweb-microservice +typing-extensions==4.15.0 + # via + # opengeodeweb-microservice + # sqlalchemy +werkzeug==3.1.3 # via # flask - # flask-cors + # opengeodeweb-microservice From 900689b0c0f5ac8ad8af54a30f436145404cc91d Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Fri, 3 Oct 2025 17:16:19 +0200 Subject: [PATCH 12/21] requirements ? --- requirements.in | 4 +-- requirements.txt | 78 +++++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/requirements.in b/requirements.in index 83ca6ff9..2d917dd5 100644 --- a/requirements.in +++ b/requirements.in @@ -5,9 +5,7 @@ opengeode-geosciences==9.4.1 opengeode-geosciencesio==5.8.0 geode-common==33.11.0 geode-viewables==3.3.0 -Flask[async]==3.0.3 -Flask-Cors==6.0.1 -werkzeug==3.0.3 flask[async]==3.1.2 flask-cors==6.0.1 +werkzeug==3.1.3 flask-sqlalchemy==3.1.1 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b09b49d8..432e2437 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,53 +2,69 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile requirements-internal.in +# pip-compile requirements.in # +asgiref==3.9.2 + # via flask blinker==1.9.0 - # via - # flask - # opengeodeweb-microservice + # via flask click==8.3.0 + # via flask +flask[async]==3.1.2 # via - # flask - # opengeodeweb-microservice -fastjsonschema==2.21.1 - # via opengeodeweb-microservice -flask==3.1.2 - # via + # -r requirements.in + # flask-cors # flask-sqlalchemy - # opengeodeweb-microservice +flask-cors==6.0.1 + # via -r requirements.in flask-sqlalchemy==3.1.1 - # via opengeodeweb-microservice -greenlet==3.2.4 + # via -r requirements.in +geode-common==33.11.0 # via - # opengeodeweb-microservice - # sqlalchemy + # -r requirements.in + # geode-viewables +geode-viewables==3.3.0 + # via -r requirements.in +greenlet==3.2.4 + # via sqlalchemy itsdangerous==2.2.0 - # via - # flask - # opengeodeweb-microservice + # via flask jinja2==3.1.6 - # via - # flask - # opengeodeweb-microservice + # via flask markupsafe==3.0.3 # via # flask # jinja2 - # opengeodeweb-microservice # werkzeug -opengeodeweb-microservice==1.0.3 - # via -r requirements-internal.in -sqlalchemy==2.0.43 +opengeode-core==15.27.4 # via - # flask-sqlalchemy - # opengeodeweb-microservice -typing-extensions==4.15.0 + # -r requirements.in + # geode-common + # geode-viewables + # opengeode-geosciences + # opengeode-geosciencesio + # opengeode-inspector + # opengeode-io +opengeode-geosciences==9.4.1 + # via + # -r requirements.in + # geode-viewables + # opengeode-geosciencesio +opengeode-geosciencesio==5.8.0 + # via -r requirements.in +opengeode-inspector==6.8.1 + # via -r requirements.in +opengeode-io==7.4.0 # via - # opengeodeweb-microservice - # sqlalchemy + # -r requirements.in + # geode-viewables + # opengeode-geosciencesio +sqlalchemy==2.0.43 + # via flask-sqlalchemy +typing-extensions==4.15.0 + # via sqlalchemy werkzeug==3.1.3 # via + # -r requirements.in # flask - # opengeodeweb-microservice + # flask-cors From 66162b05b6c2e7c68deaaf7f47146aedfc8187c5 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Sun, 5 Oct 2025 23:48:13 +0200 Subject: [PATCH 13/21] test --- src/tests/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 48cdbb22..f1e8f963 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -24,7 +24,8 @@ def configure_test_environment() -> Generator[None, None, None]: # Clean up any existing test data shutil.rmtree("./data", ignore_errors=True) - shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) + if test_data_path.exists(): + shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) # Configure app for testing app.config["TESTING"] = True @@ -39,7 +40,7 @@ def configure_test_environment() -> Generator[None, None, None]: print("Current working directory:", os.getcwd()) print("Directory contents:", os.listdir(".")) - init_database(db_path) + init_database(app, db_path) os.environ["TEST_DB_PATH"] = str(db_path) yield From b6b6e3b2a7b96ed6052208b9e130dc86304ea73f Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 10:38:17 +0200 Subject: [PATCH 14/21] tests' paths fixed --- src/opengeodeweb_back/app.py | 8 +++++++ src/tests/conftest.py | 9 ++----- src/tests/test_geode_functions.py | 2 +- src/tests/test_models_routes.py | 10 ++++---- src/tests/test_routes.py | 40 ++++++++++++++++--------------- src/tests/test_utils_functions.py | 8 +++---- 6 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index 3aa4ceb6..7dab5b99 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -65,6 +65,14 @@ def errorhandler(e): return utils_functions.handle_exception(e) +@app.route( + "/error", + methods=["POST"], +) +def return_error(): + flask.abort(500, f"Test") + + @app.route("/", methods=["POST"]) @cross_origin() def root(): diff --git a/src/tests/conftest.py b/src/tests/conftest.py index f1e8f963..5ae51f70 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -22,18 +22,14 @@ def configure_test_environment() -> Generator[None, None, None]: base_path = Path(__file__).parent test_data_path = base_path / "data" - # Clean up any existing test data shutil.rmtree("./data", ignore_errors=True) - if test_data_path.exists(): - shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) + shutil.copytree(test_data_path, f"./data/{TEST_ID}/", dirs_exist_ok=True) - # Configure app for testing app.config["TESTING"] = True app.config["SERVER_NAME"] = "TEST" app.config["DATA_FOLDER_PATH"] = "./data/" - app.config["UPLOAD_FOLDER"] = "./tests/data/" + app.config["UPLOAD_FOLDER"] = "./src/tests/data/" - # Setup database db_path = os.path.join(base_path, "data", "project.db") app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}" @@ -45,7 +41,6 @@ def configure_test_environment() -> Generator[None, None, None]: yield - # Cleanup after tests tmp_data_path = app.config.get("DATA_FOLDER_PATH") if tmp_data_path and os.path.exists(tmp_data_path): shutil.rmtree(tmp_data_path, ignore_errors=True) diff --git a/src/tests/test_geode_functions.py b/src/tests/test_geode_functions.py index 870a130a..b3c57b1c 100644 --- a/src/tests/test_geode_functions.py +++ b/src/tests/test_geode_functions.py @@ -5,7 +5,7 @@ # Third party imports # Local application imports -from src.opengeodeweb_back import geode_functions, geode_objects +from opengeodeweb_back import geode_functions, geode_objects data_folder = os.path.join(os.path.dirname(__file__), "data") diff --git a/src/tests/test_models_routes.py b/src/tests/test_models_routes.py index 687d6027..e7649ba0 100644 --- a/src/tests/test_models_routes.py +++ b/src/tests/test_models_routes.py @@ -2,18 +2,18 @@ import shutil import flask -from src.opengeodeweb_back import geode_functions +from opengeodeweb_back import geode_functions from opengeodeweb_microservice.database.data import Data from opengeodeweb_microservice.database.connection import get_session def test_model_mesh_components(client, test_id): - route = f"/models/vtm_component_indices" + route = "/opengeodeweb_back/models/vtm_component_indices" with client.application.app_context(): data_path = geode_functions.data_file_path(test_id, "viewable.vtm") os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./tests/data/cube.vtm", data_path) + shutil.copy("./src/tests/data/cube.vtm", data_path) response = client.post(route, json={"id": test_id}) assert response.status_code == 200 @@ -29,7 +29,7 @@ def test_model_mesh_components(client, test_id): def test_extract_brep_uuids(client, test_id): - route = "/models/mesh_components" + route = "/opengeodeweb_back/models/mesh_components" brep_filename = "cube.og_brep" with client.application.app_context(): @@ -42,7 +42,7 @@ def test_extract_brep_uuids(client, test_id): if session: session.commit() - src_path = os.path.join("tests", "data", brep_filename) + src_path = os.path.join("src", "tests", "data", brep_filename) dest_path = os.path.join( flask.current_app.config["DATA_FOLDER_PATH"], data_entry.id, brep_filename ) diff --git a/src/tests/test_routes.py b/src/tests/test_routes.py index a46984b5..7992887f 100644 --- a/src/tests/test_routes.py +++ b/src/tests/test_routes.py @@ -8,11 +8,11 @@ # Local application imports from opengeodeweb_microservice.database.data import Data from opengeodeweb_microservice.database.connection import get_session -from src.opengeodeweb_back import geode_functions, test_utils +from opengeodeweb_back import geode_functions, test_utils def test_allowed_files(client): - route = f"/allowed_files" + route = f"/opengeodeweb_back/allowed_files" get_full_data = lambda: {"supported_feature": "None"} json = get_full_data() response = client.post(route, json=json) @@ -27,7 +27,7 @@ def test_allowed_files(client): def test_allowed_objects(client): - route = f"/allowed_objects" + route = f"/opengeodeweb_back/allowed_objects" def get_full_data(): return { @@ -49,14 +49,14 @@ def get_full_data(): def test_upload_file(client, filename="test.og_brep"): response = client.put( - f"/upload_file", - data={"file": FileStorage(open(f"./tests/data/{filename}", "rb"))}, + f"/opengeodeweb_back/upload_file", + data={"file": FileStorage(open(f"./src/tests/data/{filename}", "rb"))}, ) assert response.status_code == 201 def test_missing_files(client): - route = f"/missing_files" + route = f"/opengeodeweb_back/missing_files" def get_full_data(): return { @@ -79,7 +79,7 @@ def get_full_data(): def test_geographic_coordinate_systems(client): - route = f"/geographic_coordinate_systems" + route = f"/opengeodeweb_back/geographic_coordinate_systems" get_full_data = lambda: {"input_geode_object": "BRep"} # Normal test with geode_object 'BRep' response = client.post(route, json=get_full_data()) @@ -94,7 +94,7 @@ def test_geographic_coordinate_systems(client): def test_inspect_file(client): - route = f"/inspect_file" + route = f"/opengeodeweb_back/inspect_file" def get_full_data(): return { @@ -115,7 +115,7 @@ def get_full_data(): def test_geode_objects_and_output_extensions(client): - route = "/geode_objects_and_output_extensions" + route = "/opengeodeweb_back/geode_objects_and_output_extensions" def get_full_data(): return { @@ -142,7 +142,7 @@ def get_full_data(): def test_save_viewable_file(client): test_upload_file(client, filename="corbi.og_brep") - route = f"/save_viewable_file" + route = f"/opengeodeweb_back/save_viewable_file" def get_full_data(): return { @@ -179,9 +179,11 @@ def test_texture_coordinates(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./tests/data/hat.vtp", data_path) + shutil.copy("./src/tests/data/hat.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" - response = client.post("/texture_coordinates", json={"id": data.id}) + response = client.post( + "/opengeodeweb_back/texture_coordinates", json={"id": data.id} + ) assert response.status_code == 200 texture_coordinates = response.json["texture_coordinates"] assert type(texture_coordinates) is list @@ -190,7 +192,7 @@ def test_texture_coordinates(client, test_id): def test_vertex_attribute_names(client, test_id): - route = f"/vertex_attribute_names" + route = f"/opengeodeweb_back/vertex_attribute_names" with client.application.app_context(): data = Data.create(geode_object="PolygonalSurface3D", input_file="test.vtp") @@ -201,7 +203,7 @@ def test_vertex_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./tests/data/test.vtp", data_path) + shutil.copy("./src/tests/data/test.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) assert response.status_code == 200 @@ -212,7 +214,7 @@ def test_vertex_attribute_names(client, test_id): def test_polygon_attribute_names(client, test_id): - route = f"/polygon_attribute_names" + route = f"/opengeodeweb_back/polygon_attribute_names" with client.application.app_context(): data = Data.create(geode_object="PolygonalSurface3D", input_file="test.vtp") @@ -223,7 +225,7 @@ def test_polygon_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./tests/data/test.vtp", data_path) + shutil.copy("./src/tests/data/test.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) assert response.status_code == 200 @@ -234,7 +236,7 @@ def test_polygon_attribute_names(client, test_id): def test_polyhedron_attribute_names(client, test_id): - route = f"/polyhedron_attribute_names" + route = f"/opengeodeweb_back/polyhedron_attribute_names" with client.application.app_context(): data = Data.create(geode_object="PolyhedralSolid3D", input_file="test.vtu") @@ -245,7 +247,7 @@ def test_polyhedron_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./tests/data/test.vtu", data_path) + shutil.copy("./src/tests/data/test.vtu", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) print(response.json) @@ -257,7 +259,7 @@ def test_polyhedron_attribute_names(client, test_id): def test_create_point(client): - route = f"/create_point" + route = f"/opengeodeweb_back/create_point" get_full_data = lambda: {"title": "test_point", "x": 1, "y": 2, "z": 3} # Normal test with all keys diff --git a/src/tests/test_utils_functions.py b/src/tests/test_utils_functions.py index c7e8bce7..5c3b1ba1 100644 --- a/src/tests/test_utils_functions.py +++ b/src/tests/test_utils_functions.py @@ -10,7 +10,7 @@ # Local application imports from opengeodeweb_microservice.database.data import Data from opengeodeweb_microservice.database.connection import get_session -from src.opengeodeweb_back import geode_functions, utils_functions +from opengeodeweb_back import geode_functions, utils_functions def test_increment_request_counter(app_context): @@ -99,7 +99,7 @@ def test_save_all_viewables_and_return_info(client): assert os.path.exists(expected_db_path) geode_object = "BRep" - data = geode_functions.load(geode_object, "./tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") input_file = "test.og_brep" additional_files = ["additional_file.txt"] @@ -134,7 +134,7 @@ def test_save_all_viewables_commits_to_db(client): app = client.application with app.app_context(): geode_object = "BRep" - data = geode_functions.load(geode_object, "./tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") input_file = "test.og_brep" result = utils_functions.save_all_viewables_and_return_info( geode_object, data, input_file @@ -156,7 +156,7 @@ def test_generate_native_viewable_and_light_viewable_from_object(client): app = client.application with app.app_context(): geode_object = "BRep" - data = geode_functions.load(geode_object, "./tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") result = ( utils_functions.generate_native_viewable_and_light_viewable_from_object( From 78398b5f115593ffb36486a93e3918e1b5b8e994 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 10:41:07 +0200 Subject: [PATCH 15/21] fix(refacto): app and app config from Vease-back From 6da995206ef4b927bd7d04adad56dbc0b06f932c Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Mon, 6 Oct 2025 08:43:31 +0000 Subject: [PATCH 16/21] Apply prepare changes --- requirements.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 432e2437..de06a245 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,15 +2,15 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile requirements.in +# pip-compile --output-file=./requirements.txt --pre ./requirements.in # -asgiref==3.9.2 +asgiref~=3.10 # via flask -blinker==1.9.0 +blinker~=1.9 # via flask -click==8.3.0 +click~=8.3 # via flask -flask[async]==3.1.2 +flask[async]~=3.1 # via # -r requirements.in # flask-cors @@ -25,13 +25,13 @@ geode-common==33.11.0 # geode-viewables geode-viewables==3.3.0 # via -r requirements.in -greenlet==3.2.4 +greenlet~=3.2 # via sqlalchemy -itsdangerous==2.2.0 +itsdangerous~=2.2 # via flask -jinja2==3.1.6 +jinja2~=3.1 # via flask -markupsafe==3.0.3 +markupsafe~=3.0 # via # flask # jinja2 @@ -59,9 +59,9 @@ opengeode-io==7.4.0 # -r requirements.in # geode-viewables # opengeode-geosciencesio -sqlalchemy==2.0.43 +sqlalchemy~=2.0 # via flask-sqlalchemy -typing-extensions==4.15.0 +typing-extensions~=4.15 # via sqlalchemy werkzeug==3.1.3 # via From d6f313d483a3d0a0f530110745fb0ac731c0f1a8 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 10:51:46 +0200 Subject: [PATCH 17/21] revert moving tests folder --- {src/tests => tests}/__init__.py | 0 {src/tests => tests}/conftest.py | 0 {src/tests => tests}/data/corbi.og_brep | Bin {src/tests => tests}/data/cube.og_brep | Bin {src/tests => tests}/data/cube.vtm | 0 {src/tests => tests}/data/hat.vtp | 0 {src/tests => tests}/data/polygon_attribute.vtp | 0 {src/tests => tests}/data/polyhedron_attribute.vtu | 0 {src/tests => tests}/data/test.bmp | Bin {src/tests => tests}/data/test.dat | 0 {src/tests => tests}/data/test.dem | 0 {src/tests => tests}/data/test.dev | 0 {src/tests => tests}/data/test.dxf | 0 {src/tests => tests}/data/test.grdecl | 0 {src/tests => tests}/data/test.jpg | Bin {src/tests => tests}/data/test.lso | 0 {src/tests => tests}/data/test.ml | 0 {src/tests => tests}/data/test.msh | 0 {src/tests => tests}/data/test.obj | 0 {src/tests => tests}/data/test.og_brep | Bin {src/tests => tests}/data/test.og_edc2d | Bin {src/tests => tests}/data/test.og_edc3d | Bin {src/tests => tests}/data/test.og_grp | Bin {src/tests => tests}/data/test.og_hso3d | Bin {src/tests => tests}/data/test.og_img2d | Bin {src/tests => tests}/data/test.og_img3d | Bin {src/tests => tests}/data/test.og_istrm | Bin {src/tests => tests}/data/test.og_ixsctn | Bin {src/tests => tests}/data/test.og_lrgd2d | Bin {src/tests => tests}/data/test.og_lrgd3d | Bin {src/tests => tests}/data/test.og_psf2d | Bin {src/tests => tests}/data/test.og_psf3d | Bin {src/tests => tests}/data/test.og_pso3d | Bin {src/tests => tests}/data/test.og_pts2d | Bin {src/tests => tests}/data/test.og_pts3d | Bin {src/tests => tests}/data/test.og_rgd2d | Bin {src/tests => tests}/data/test.og_rgd3d | Bin {src/tests => tests}/data/test.og_sctn | Bin {src/tests => tests}/data/test.og_strm | Bin {src/tests => tests}/data/test.og_tsf2d | Bin {src/tests => tests}/data/test.og_tsf3d | Bin {src/tests => tests}/data/test.og_tso3d | Bin {src/tests => tests}/data/test.og_vts | Bin {src/tests => tests}/data/test.og_xsctn | Bin {src/tests => tests}/data/test.pl | 0 {src/tests => tests}/data/test.ply | 0 {src/tests => tests}/data/test.png | Bin {src/tests => tests}/data/test.shp | Bin {src/tests => tests}/data/test.shx | Bin {src/tests => tests}/data/test.shz | Bin {src/tests => tests}/data/test.smesh | 0 {src/tests => tests}/data/test.stl | 0 {src/tests => tests}/data/test.svg | 0 {src/tests => tests}/data/test.tif | Bin {src/tests => tests}/data/test.tiff | Bin {src/tests => tests}/data/test.ts | 0 {src/tests => tests}/data/test.txt | 0 {src/tests => tests}/data/test.vo | 0 {src/tests => tests}/data/test.vs | 0 {src/tests => tests}/data/test.vti | 0 {src/tests => tests}/data/test.vtp | 0 {src/tests => tests}/data/test.vtu | 0 {src/tests => tests}/data/test.wl | 0 {src/tests => tests}/data/test__ascii@@ | 0 {src/tests => tests}/data/vertex_attribute.vtp | 0 {src/tests => tests}/test_geode_functions.py | 0 {src/tests => tests}/test_models_routes.py | 0 {src/tests => tests}/test_routes.py | 0 {src/tests => tests}/test_utils_functions.py | 0 69 files changed, 0 insertions(+), 0 deletions(-) rename {src/tests => tests}/__init__.py (100%) rename {src/tests => tests}/conftest.py (100%) rename {src/tests => tests}/data/corbi.og_brep (100%) rename {src/tests => tests}/data/cube.og_brep (100%) rename {src/tests => tests}/data/cube.vtm (100%) rename {src/tests => tests}/data/hat.vtp (100%) rename {src/tests => tests}/data/polygon_attribute.vtp (100%) rename {src/tests => tests}/data/polyhedron_attribute.vtu (100%) rename {src/tests => tests}/data/test.bmp (100%) rename {src/tests => tests}/data/test.dat (100%) rename {src/tests => tests}/data/test.dem (100%) rename {src/tests => tests}/data/test.dev (100%) rename {src/tests => tests}/data/test.dxf (100%) rename {src/tests => tests}/data/test.grdecl (100%) rename {src/tests => tests}/data/test.jpg (100%) rename {src/tests => tests}/data/test.lso (100%) rename {src/tests => tests}/data/test.ml (100%) rename {src/tests => tests}/data/test.msh (100%) rename {src/tests => tests}/data/test.obj (100%) rename {src/tests => tests}/data/test.og_brep (100%) rename {src/tests => tests}/data/test.og_edc2d (100%) rename {src/tests => tests}/data/test.og_edc3d (100%) rename {src/tests => tests}/data/test.og_grp (100%) rename {src/tests => tests}/data/test.og_hso3d (100%) rename {src/tests => tests}/data/test.og_img2d (100%) rename {src/tests => tests}/data/test.og_img3d (100%) rename {src/tests => tests}/data/test.og_istrm (100%) rename {src/tests => tests}/data/test.og_ixsctn (100%) rename {src/tests => tests}/data/test.og_lrgd2d (100%) rename {src/tests => tests}/data/test.og_lrgd3d (100%) rename {src/tests => tests}/data/test.og_psf2d (100%) rename {src/tests => tests}/data/test.og_psf3d (100%) rename {src/tests => tests}/data/test.og_pso3d (100%) rename {src/tests => tests}/data/test.og_pts2d (100%) rename {src/tests => tests}/data/test.og_pts3d (100%) rename {src/tests => tests}/data/test.og_rgd2d (100%) rename {src/tests => tests}/data/test.og_rgd3d (100%) rename {src/tests => tests}/data/test.og_sctn (100%) rename {src/tests => tests}/data/test.og_strm (100%) rename {src/tests => tests}/data/test.og_tsf2d (100%) rename {src/tests => tests}/data/test.og_tsf3d (100%) rename {src/tests => tests}/data/test.og_tso3d (100%) rename {src/tests => tests}/data/test.og_vts (100%) rename {src/tests => tests}/data/test.og_xsctn (100%) rename {src/tests => tests}/data/test.pl (100%) rename {src/tests => tests}/data/test.ply (100%) rename {src/tests => tests}/data/test.png (100%) rename {src/tests => tests}/data/test.shp (100%) rename {src/tests => tests}/data/test.shx (100%) rename {src/tests => tests}/data/test.shz (100%) rename {src/tests => tests}/data/test.smesh (100%) rename {src/tests => tests}/data/test.stl (100%) rename {src/tests => tests}/data/test.svg (100%) rename {src/tests => tests}/data/test.tif (100%) rename {src/tests => tests}/data/test.tiff (100%) rename {src/tests => tests}/data/test.ts (100%) rename {src/tests => tests}/data/test.txt (100%) rename {src/tests => tests}/data/test.vo (100%) rename {src/tests => tests}/data/test.vs (100%) rename {src/tests => tests}/data/test.vti (100%) rename {src/tests => tests}/data/test.vtp (100%) rename {src/tests => tests}/data/test.vtu (100%) rename {src/tests => tests}/data/test.wl (100%) rename {src/tests => tests}/data/test__ascii@@ (100%) rename {src/tests => tests}/data/vertex_attribute.vtp (100%) rename {src/tests => tests}/test_geode_functions.py (100%) rename {src/tests => tests}/test_models_routes.py (100%) rename {src/tests => tests}/test_routes.py (100%) rename {src/tests => tests}/test_utils_functions.py (100%) diff --git a/src/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/tests/__init__.py rename to tests/__init__.py diff --git a/src/tests/conftest.py b/tests/conftest.py similarity index 100% rename from src/tests/conftest.py rename to tests/conftest.py diff --git a/src/tests/data/corbi.og_brep b/tests/data/corbi.og_brep similarity index 100% rename from src/tests/data/corbi.og_brep rename to tests/data/corbi.og_brep diff --git a/src/tests/data/cube.og_brep b/tests/data/cube.og_brep similarity index 100% rename from src/tests/data/cube.og_brep rename to tests/data/cube.og_brep diff --git a/src/tests/data/cube.vtm b/tests/data/cube.vtm similarity index 100% rename from src/tests/data/cube.vtm rename to tests/data/cube.vtm diff --git a/src/tests/data/hat.vtp b/tests/data/hat.vtp similarity index 100% rename from src/tests/data/hat.vtp rename to tests/data/hat.vtp diff --git a/src/tests/data/polygon_attribute.vtp b/tests/data/polygon_attribute.vtp similarity index 100% rename from src/tests/data/polygon_attribute.vtp rename to tests/data/polygon_attribute.vtp diff --git a/src/tests/data/polyhedron_attribute.vtu b/tests/data/polyhedron_attribute.vtu similarity index 100% rename from src/tests/data/polyhedron_attribute.vtu rename to tests/data/polyhedron_attribute.vtu diff --git a/src/tests/data/test.bmp b/tests/data/test.bmp similarity index 100% rename from src/tests/data/test.bmp rename to tests/data/test.bmp diff --git a/src/tests/data/test.dat b/tests/data/test.dat similarity index 100% rename from src/tests/data/test.dat rename to tests/data/test.dat diff --git a/src/tests/data/test.dem b/tests/data/test.dem similarity index 100% rename from src/tests/data/test.dem rename to tests/data/test.dem diff --git a/src/tests/data/test.dev b/tests/data/test.dev similarity index 100% rename from src/tests/data/test.dev rename to tests/data/test.dev diff --git a/src/tests/data/test.dxf b/tests/data/test.dxf similarity index 100% rename from src/tests/data/test.dxf rename to tests/data/test.dxf diff --git a/src/tests/data/test.grdecl b/tests/data/test.grdecl similarity index 100% rename from src/tests/data/test.grdecl rename to tests/data/test.grdecl diff --git a/src/tests/data/test.jpg b/tests/data/test.jpg similarity index 100% rename from src/tests/data/test.jpg rename to tests/data/test.jpg diff --git a/src/tests/data/test.lso b/tests/data/test.lso similarity index 100% rename from src/tests/data/test.lso rename to tests/data/test.lso diff --git a/src/tests/data/test.ml b/tests/data/test.ml similarity index 100% rename from src/tests/data/test.ml rename to tests/data/test.ml diff --git a/src/tests/data/test.msh b/tests/data/test.msh similarity index 100% rename from src/tests/data/test.msh rename to tests/data/test.msh diff --git a/src/tests/data/test.obj b/tests/data/test.obj similarity index 100% rename from src/tests/data/test.obj rename to tests/data/test.obj diff --git a/src/tests/data/test.og_brep b/tests/data/test.og_brep similarity index 100% rename from src/tests/data/test.og_brep rename to tests/data/test.og_brep diff --git a/src/tests/data/test.og_edc2d b/tests/data/test.og_edc2d similarity index 100% rename from src/tests/data/test.og_edc2d rename to tests/data/test.og_edc2d diff --git a/src/tests/data/test.og_edc3d b/tests/data/test.og_edc3d similarity index 100% rename from src/tests/data/test.og_edc3d rename to tests/data/test.og_edc3d diff --git a/src/tests/data/test.og_grp b/tests/data/test.og_grp similarity index 100% rename from src/tests/data/test.og_grp rename to tests/data/test.og_grp diff --git a/src/tests/data/test.og_hso3d b/tests/data/test.og_hso3d similarity index 100% rename from src/tests/data/test.og_hso3d rename to tests/data/test.og_hso3d diff --git a/src/tests/data/test.og_img2d b/tests/data/test.og_img2d similarity index 100% rename from src/tests/data/test.og_img2d rename to tests/data/test.og_img2d diff --git a/src/tests/data/test.og_img3d b/tests/data/test.og_img3d similarity index 100% rename from src/tests/data/test.og_img3d rename to tests/data/test.og_img3d diff --git a/src/tests/data/test.og_istrm b/tests/data/test.og_istrm similarity index 100% rename from src/tests/data/test.og_istrm rename to tests/data/test.og_istrm diff --git a/src/tests/data/test.og_ixsctn b/tests/data/test.og_ixsctn similarity index 100% rename from src/tests/data/test.og_ixsctn rename to tests/data/test.og_ixsctn diff --git a/src/tests/data/test.og_lrgd2d b/tests/data/test.og_lrgd2d similarity index 100% rename from src/tests/data/test.og_lrgd2d rename to tests/data/test.og_lrgd2d diff --git a/src/tests/data/test.og_lrgd3d b/tests/data/test.og_lrgd3d similarity index 100% rename from src/tests/data/test.og_lrgd3d rename to tests/data/test.og_lrgd3d diff --git a/src/tests/data/test.og_psf2d b/tests/data/test.og_psf2d similarity index 100% rename from src/tests/data/test.og_psf2d rename to tests/data/test.og_psf2d diff --git a/src/tests/data/test.og_psf3d b/tests/data/test.og_psf3d similarity index 100% rename from src/tests/data/test.og_psf3d rename to tests/data/test.og_psf3d diff --git a/src/tests/data/test.og_pso3d b/tests/data/test.og_pso3d similarity index 100% rename from src/tests/data/test.og_pso3d rename to tests/data/test.og_pso3d diff --git a/src/tests/data/test.og_pts2d b/tests/data/test.og_pts2d similarity index 100% rename from src/tests/data/test.og_pts2d rename to tests/data/test.og_pts2d diff --git a/src/tests/data/test.og_pts3d b/tests/data/test.og_pts3d similarity index 100% rename from src/tests/data/test.og_pts3d rename to tests/data/test.og_pts3d diff --git a/src/tests/data/test.og_rgd2d b/tests/data/test.og_rgd2d similarity index 100% rename from src/tests/data/test.og_rgd2d rename to tests/data/test.og_rgd2d diff --git a/src/tests/data/test.og_rgd3d b/tests/data/test.og_rgd3d similarity index 100% rename from src/tests/data/test.og_rgd3d rename to tests/data/test.og_rgd3d diff --git a/src/tests/data/test.og_sctn b/tests/data/test.og_sctn similarity index 100% rename from src/tests/data/test.og_sctn rename to tests/data/test.og_sctn diff --git a/src/tests/data/test.og_strm b/tests/data/test.og_strm similarity index 100% rename from src/tests/data/test.og_strm rename to tests/data/test.og_strm diff --git a/src/tests/data/test.og_tsf2d b/tests/data/test.og_tsf2d similarity index 100% rename from src/tests/data/test.og_tsf2d rename to tests/data/test.og_tsf2d diff --git a/src/tests/data/test.og_tsf3d b/tests/data/test.og_tsf3d similarity index 100% rename from src/tests/data/test.og_tsf3d rename to tests/data/test.og_tsf3d diff --git a/src/tests/data/test.og_tso3d b/tests/data/test.og_tso3d similarity index 100% rename from src/tests/data/test.og_tso3d rename to tests/data/test.og_tso3d diff --git a/src/tests/data/test.og_vts b/tests/data/test.og_vts similarity index 100% rename from src/tests/data/test.og_vts rename to tests/data/test.og_vts diff --git a/src/tests/data/test.og_xsctn b/tests/data/test.og_xsctn similarity index 100% rename from src/tests/data/test.og_xsctn rename to tests/data/test.og_xsctn diff --git a/src/tests/data/test.pl b/tests/data/test.pl similarity index 100% rename from src/tests/data/test.pl rename to tests/data/test.pl diff --git a/src/tests/data/test.ply b/tests/data/test.ply similarity index 100% rename from src/tests/data/test.ply rename to tests/data/test.ply diff --git a/src/tests/data/test.png b/tests/data/test.png similarity index 100% rename from src/tests/data/test.png rename to tests/data/test.png diff --git a/src/tests/data/test.shp b/tests/data/test.shp similarity index 100% rename from src/tests/data/test.shp rename to tests/data/test.shp diff --git a/src/tests/data/test.shx b/tests/data/test.shx similarity index 100% rename from src/tests/data/test.shx rename to tests/data/test.shx diff --git a/src/tests/data/test.shz b/tests/data/test.shz similarity index 100% rename from src/tests/data/test.shz rename to tests/data/test.shz diff --git a/src/tests/data/test.smesh b/tests/data/test.smesh similarity index 100% rename from src/tests/data/test.smesh rename to tests/data/test.smesh diff --git a/src/tests/data/test.stl b/tests/data/test.stl similarity index 100% rename from src/tests/data/test.stl rename to tests/data/test.stl diff --git a/src/tests/data/test.svg b/tests/data/test.svg similarity index 100% rename from src/tests/data/test.svg rename to tests/data/test.svg diff --git a/src/tests/data/test.tif b/tests/data/test.tif similarity index 100% rename from src/tests/data/test.tif rename to tests/data/test.tif diff --git a/src/tests/data/test.tiff b/tests/data/test.tiff similarity index 100% rename from src/tests/data/test.tiff rename to tests/data/test.tiff diff --git a/src/tests/data/test.ts b/tests/data/test.ts similarity index 100% rename from src/tests/data/test.ts rename to tests/data/test.ts diff --git a/src/tests/data/test.txt b/tests/data/test.txt similarity index 100% rename from src/tests/data/test.txt rename to tests/data/test.txt diff --git a/src/tests/data/test.vo b/tests/data/test.vo similarity index 100% rename from src/tests/data/test.vo rename to tests/data/test.vo diff --git a/src/tests/data/test.vs b/tests/data/test.vs similarity index 100% rename from src/tests/data/test.vs rename to tests/data/test.vs diff --git a/src/tests/data/test.vti b/tests/data/test.vti similarity index 100% rename from src/tests/data/test.vti rename to tests/data/test.vti diff --git a/src/tests/data/test.vtp b/tests/data/test.vtp similarity index 100% rename from src/tests/data/test.vtp rename to tests/data/test.vtp diff --git a/src/tests/data/test.vtu b/tests/data/test.vtu similarity index 100% rename from src/tests/data/test.vtu rename to tests/data/test.vtu diff --git a/src/tests/data/test.wl b/tests/data/test.wl similarity index 100% rename from src/tests/data/test.wl rename to tests/data/test.wl diff --git a/src/tests/data/test__ascii@@ b/tests/data/test__ascii@@ similarity index 100% rename from src/tests/data/test__ascii@@ rename to tests/data/test__ascii@@ diff --git a/src/tests/data/vertex_attribute.vtp b/tests/data/vertex_attribute.vtp similarity index 100% rename from src/tests/data/vertex_attribute.vtp rename to tests/data/vertex_attribute.vtp diff --git a/src/tests/test_geode_functions.py b/tests/test_geode_functions.py similarity index 100% rename from src/tests/test_geode_functions.py rename to tests/test_geode_functions.py diff --git a/src/tests/test_models_routes.py b/tests/test_models_routes.py similarity index 100% rename from src/tests/test_models_routes.py rename to tests/test_models_routes.py diff --git a/src/tests/test_routes.py b/tests/test_routes.py similarity index 100% rename from src/tests/test_routes.py rename to tests/test_routes.py diff --git a/src/tests/test_utils_functions.py b/tests/test_utils_functions.py similarity index 100% rename from src/tests/test_utils_functions.py rename to tests/test_utils_functions.py From c0e82c43258180b9e74f2b610dda54e2858681aa Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 11:11:07 +0200 Subject: [PATCH 18/21] finished moving tests, better app.py --- requirements.in | 2 +- src/opengeodeweb_back/app.py | 19 ++++--------------- tests/conftest.py | 2 +- tests/test_models_routes.py | 4 ++-- tests/test_routes.py | 10 +++++----- tests/test_utils_functions.py | 6 +++--- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/requirements.in b/requirements.in index 2d917dd5..1a55b764 100644 --- a/requirements.in +++ b/requirements.in @@ -7,5 +7,5 @@ geode-common==33.11.0 geode-viewables==3.3.0 flask[async]==3.1.2 flask-cors==6.0.1 -werkzeug==3.1.3 +werkzeug==3.1.2 flask-sqlalchemy==3.1.1 \ No newline at end of file diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index 7dab5b99..853d29d0 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -35,13 +35,6 @@ SECONDS_BETWEEN_SHUTDOWNS = float(app.config.get("SECONDS_BETWEEN_SHUTDOWNS")) -def get_db_path_from_config(): - database_uri = f"{os.path.abspath( - os.path.join(app.config.get('DATA_FOLDER_PATH'), app.config.get('DATABASE_FILENAME')) - )}" - return database_uri - - app.register_blueprint( blueprint_routes.routes, url_prefix="/opengeodeweb_back", @@ -142,14 +135,10 @@ def run_server(): flush=True, ) - db_path = get_db_path_from_config() - print("db_path", db_path, flush=True) - if db_path: - db_dir = os.path.dirname(db_path) - if db_dir and not os.path.exists(db_dir): - os.makedirs(db_dir, exist_ok=True) - init_database(db_path) - print(f"Database initialized at: {db_path}") + db_path = os.path.join(args.data_folder_path, app.config.get("DATABASE_FILENAME")) + os.makedirs(os.path.dirname(db_path), exist_ok=True) + init_database(db_path) + print(f"Database initialized at: {db_path}", flush=True) app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL) diff --git a/tests/conftest.py b/tests/conftest.py index 5ae51f70..04a50e03 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,7 +28,7 @@ def configure_test_environment() -> Generator[None, None, None]: app.config["TESTING"] = True app.config["SERVER_NAME"] = "TEST" app.config["DATA_FOLDER_PATH"] = "./data/" - app.config["UPLOAD_FOLDER"] = "./src/tests/data/" + app.config["UPLOAD_FOLDER"] = "./tests/data/" db_path = os.path.join(base_path, "data", "project.db") app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}" diff --git a/tests/test_models_routes.py b/tests/test_models_routes.py index e7649ba0..83fa4cbd 100644 --- a/tests/test_models_routes.py +++ b/tests/test_models_routes.py @@ -13,7 +13,7 @@ def test_model_mesh_components(client, test_id): with client.application.app_context(): data_path = geode_functions.data_file_path(test_id, "viewable.vtm") os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./src/tests/data/cube.vtm", data_path) + shutil.copy("./tests/data/cube.vtm", data_path) response = client.post(route, json={"id": test_id}) assert response.status_code == 200 @@ -42,7 +42,7 @@ def test_extract_brep_uuids(client, test_id): if session: session.commit() - src_path = os.path.join("src", "tests", "data", brep_filename) + src_path = os.path.join("tests", "data", brep_filename) dest_path = os.path.join( flask.current_app.config["DATA_FOLDER_PATH"], data_entry.id, brep_filename ) diff --git a/tests/test_routes.py b/tests/test_routes.py index 7992887f..fd1095e2 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -50,7 +50,7 @@ def get_full_data(): def test_upload_file(client, filename="test.og_brep"): response = client.put( f"/opengeodeweb_back/upload_file", - data={"file": FileStorage(open(f"./src/tests/data/{filename}", "rb"))}, + data={"file": FileStorage(open(f"./tests/data/{filename}", "rb"))}, ) assert response.status_code == 201 @@ -179,7 +179,7 @@ def test_texture_coordinates(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./src/tests/data/hat.vtp", data_path) + shutil.copy("./tests/data/hat.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post( "/opengeodeweb_back/texture_coordinates", json={"id": data.id} @@ -203,7 +203,7 @@ def test_vertex_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./src/tests/data/test.vtp", data_path) + shutil.copy("./tests/data/test.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) assert response.status_code == 200 @@ -225,7 +225,7 @@ def test_polygon_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./src/tests/data/test.vtp", data_path) + shutil.copy("./tests/data/test.vtp", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) assert response.status_code == 200 @@ -247,7 +247,7 @@ def test_polyhedron_attribute_names(client, test_id): data_path = geode_functions.data_file_path(data.id, data.native_file_name) os.makedirs(os.path.dirname(data_path), exist_ok=True) - shutil.copy("./src/tests/data/test.vtu", data_path) + shutil.copy("./tests/data/test.vtu", data_path) assert os.path.exists(data_path), f"File not found at {data_path}" response = client.post(route, json={"id": data.id}) print(response.json) diff --git a/tests/test_utils_functions.py b/tests/test_utils_functions.py index 5c3b1ba1..befcc14d 100644 --- a/tests/test_utils_functions.py +++ b/tests/test_utils_functions.py @@ -99,7 +99,7 @@ def test_save_all_viewables_and_return_info(client): assert os.path.exists(expected_db_path) geode_object = "BRep" - data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./tests/data/test.og_brep") input_file = "test.og_brep" additional_files = ["additional_file.txt"] @@ -134,7 +134,7 @@ def test_save_all_viewables_commits_to_db(client): app = client.application with app.app_context(): geode_object = "BRep" - data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./tests/data/test.og_brep") input_file = "test.og_brep" result = utils_functions.save_all_viewables_and_return_info( geode_object, data, input_file @@ -156,7 +156,7 @@ def test_generate_native_viewable_and_light_viewable_from_object(client): app = client.application with app.app_context(): geode_object = "BRep" - data = geode_functions.load(geode_object, "./src/tests/data/test.og_brep") + data = geode_functions.load(geode_object, "./tests/data/test.og_brep") result = ( utils_functions.generate_native_viewable_and_light_viewable_from_object( From 2c9badb013dc58783c57a8ed60045d11c8407e38 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Mon, 6 Oct 2025 09:11:38 +0000 Subject: [PATCH 19/21] Apply prepare changes --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index de06a245..d94d0c61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ sqlalchemy~=2.0 # via flask-sqlalchemy typing-extensions~=4.15 # via sqlalchemy -werkzeug==3.1.3 +werkzeug==3.1.2 # via # -r requirements.in # flask From 638fdcbc4144f7241899561f098e6b5615a847eb Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 11:18:07 +0200 Subject: [PATCH 20/21] type app.py --- src/opengeodeweb_back/app.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index 853d29d0..ac7a7451 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -3,9 +3,11 @@ import argparse import os import time +from typing import Any import flask -import flask_cors +import flask_cors # type: ignore +from flask import Flask, Response from flask_cors import cross_origin from werkzeug.exceptions import HTTPException @@ -16,7 +18,7 @@ """ Global config """ -app = flask.Flask(__name__) +app: Flask = flask.Flask(__name__) """ Config variables """ FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False @@ -26,13 +28,15 @@ else: app.config.from_object(app_config.DevConfig) -DEFAULT_HOST = app.config.get("DEFAULT_HOST") -DEFAULT_PORT = int(app.config.get("DEFAULT_PORT")) -DEFAULT_DATA_FOLDER_PATH = app.config.get("DEFAULT_DATA_FOLDER_PATH") -ORIGINS = app.config.get("ORIGINS") -TIMEOUT = int(app.config.get("MINUTES_BEFORE_TIMEOUT")) -SSL = app.config.get("SSL") -SECONDS_BETWEEN_SHUTDOWNS = float(app.config.get("SECONDS_BETWEEN_SHUTDOWNS")) +DEFAULT_HOST: str = app.config.get("DEFAULT_HOST") or "localhost" +DEFAULT_PORT: int = int(app.config.get("DEFAULT_PORT") or 5000) +DEFAULT_DATA_FOLDER_PATH: str = app.config.get("DEFAULT_DATA_FOLDER_PATH") or "./data" +ORIGINS: Any = app.config.get("ORIGINS") +TIMEOUT: int = int(app.config.get("MINUTES_BEFORE_TIMEOUT") or 30) +SSL: Any = app.config.get("SSL") +SECONDS_BETWEEN_SHUTDOWNS: float = float( + app.config.get("SECONDS_BETWEEN_SHUTDOWNS") or 60.0 +) app.register_blueprint( @@ -54,7 +58,7 @@ @app.errorhandler(HTTPException) -def errorhandler(e): +def errorhandler(e: HTTPException) -> tuple[dict[str, Any], int] | Response: return utils_functions.handle_exception(e) @@ -62,13 +66,13 @@ def errorhandler(e): "/error", methods=["POST"], ) -def return_error(): +def return_error() -> None: flask.abort(500, f"Test") @app.route("/", methods=["POST"]) @cross_origin() -def root(): +def root() -> Response: return flask.make_response({}, 200) @@ -79,7 +83,7 @@ def kill() -> None: os._exit(0) -def run_server(): +def run_server() -> None: parser = argparse.ArgumentParser( prog="OpenGeodeWeb-Back", description="Backend server for OpenGeodeWeb" ) @@ -135,7 +139,8 @@ def run_server(): flush=True, ) - db_path = os.path.join(args.data_folder_path, app.config.get("DATABASE_FILENAME")) + db_filename: str = app.config.get("DATABASE_FILENAME") or "database.db" + db_path = os.path.join(args.data_folder_path, db_filename) os.makedirs(os.path.dirname(db_path), exist_ok=True) init_database(db_path) print(f"Database initialized at: {db_path}", flush=True) From 39e2bb5bd7787dc3bbb246afe1c956c1db294d57 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 6 Oct 2025 11:26:01 +0200 Subject: [PATCH 21/21] typ app.py --- src/opengeodeweb_back/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index ac7a7451..48381159 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -66,8 +66,9 @@ def errorhandler(e: HTTPException) -> tuple[dict[str, Any], int] | Response: "/error", methods=["POST"], ) -def return_error() -> None: +def return_error() -> Response: flask.abort(500, f"Test") + return flask.make_response({}, 500) @app.route("/", methods=["POST"]) @@ -142,7 +143,9 @@ def run_server() -> None: db_filename: str = app.config.get("DATABASE_FILENAME") or "database.db" db_path = os.path.join(args.data_folder_path, db_filename) os.makedirs(os.path.dirname(db_path), exist_ok=True) - init_database(db_path) + app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}" + app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False + init_database(app, db_filename) print(f"Database initialized at: {db_path}", flush=True) app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)