5050 docker exec qgis-testing-environment sh -c "mkdir -p /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/"
5151 docker exec qgis-testing-environment sh -c "rm -f /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME"
5252 docker exec qgis-testing-environment sh -c "ln -s /tests_directory/$PLUGIN_NAME /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME"
53-
54- # ENDRING HER: Lagt til 'coverage' i installasjonen
5553 docker exec qgis-testing-environment sh -c "pip3 install --break-system-packages -r /tests_directory/REQUIREMENTS_TESTING.txt coverage"
5654
5755 docker exec qgis-testing-environment sh -c "ls -l /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/"
@@ -62,10 +60,57 @@ jobs:
6260 docker exec qgis-testing-environment sh -c "touch /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool/__init__.py"
6361 docker exec qgis-testing-environment ls -la /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool
6462
63+ - name : Create Pytest configuration (conftest.py)
64+ run : |
65+ docker exec qgis-testing-environment sh -c 'cat <<EOF > /tests_directory/conftest.py
66+ import pytest
67+ from qgis.core import QgsApplication
68+ import os
69+ import sys
70+
71+ # Legg til plugin-roten og submodule-mappen i sys.path
72+ plugin_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "geovita_processing_plugin"))
73+ submodule_path = os.path.join(plugin_root, "REMEDY_GIS_RiskTool")
74+ sys.path.insert(0, plugin_root)
75+ sys.path.insert(0, submodule_path)
76+
77+ @pytest.fixture(scope="session", autouse=True)
78+ def init_qgis_processing(qgis_app) :
79+ " " " Initialiserer QGIS Processing framework og registrerer plugin-provider." " "
80+
81+ print("Initializing QGIS Processing Framework...")
82+ try :
83+ from processing.core.Processing import Processing
84+ Processing.initialize()
85+ print("Processing Framework Initialized.")
86+ except ImportError as e :
87+ print(f"Could not import Processing : {e}")
88+ pytest.skip("Failed to import QGIS Processing framework")
89+
90+ print("Registering Geovita provider...")
91+ try :
92+ from geovita_processing_plugin_provider import Geovita_processing_pluginProvider
93+ provider = Geovita_processing_pluginProvider()
94+ if QgsApplication.processingRegistry().addProvider(provider) :
95+ print(f"Successfully added provider : {provider.id()}")
96+ else :
97+ print("Failed to add provider.")
98+ except ImportError as e :
99+ print(f"Could not import Geovita provider : {e}")
100+ pytest.skip("Failed to import Geovita provider")
101+
102+ yield
103+
104+ # Nedrigging
105+ print("Deinitializing Processing Framework...")
106+ QgsApplication.processingRegistry().removeProvider(provider.id())
107+ Processing.deinitialize()
108+ EOF'
109+
65110 - name : Docker run plugin tests
66111 run : |
67- # ENDRING HER: Setter PYTHONPATH til å inkludere submodule-mappen før pytest kjøres
68- docker exec qgis-testing-environment sh -c "cd /tests_directory && export PYTHONPATH=$PYTHONPATH:./geovita_processing_plugin/REMEDY_GIS_RiskTool && xvfb-run pytest"
112+ # conftest.py håndterer nå all nødvendig oppsett
113+ docker exec qgis-testing-environment sh -c "cd /tests_directory && xvfb-run pytest"
69114
70115 Check-code-quality :
71116 runs-on : ubuntu-latest
0 commit comments