|
8 | 8 | paths: |
9 | 9 | - "geovita_processing_plugin/**" |
10 | 10 | - ".github/workflows/test_plugin.yml" |
| 11 | + - "conftest.py" # La til denne for å trigge på endringer i conftest |
11 | 12 | pull_request: |
12 | 13 | branches: |
13 | 14 | - main |
14 | 15 | - dev |
15 | 16 | paths: |
16 | 17 | - "geovita_processing_plugin/**" |
17 | 18 | - ".github/workflows/test_plugin.yml" |
| 19 | + - "conftest.py" |
18 | 20 | workflow_dispatch: |
19 | 21 |
|
20 | 22 | env: |
@@ -60,56 +62,11 @@ jobs: |
60 | 62 | docker exec qgis-testing-environment sh -c "touch /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool/__init__.py" |
61 | 63 | docker exec qgis-testing-environment ls -la /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool |
62 | 64 | |
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 | | - |
| 65 | + # FJERNET STEGET "Create Pytest configuration (conftest.py)" |
| 66 | + |
110 | 67 | - name: Docker run plugin tests |
111 | 68 | run: | |
112 | | - # conftest.py håndterer nå all nødvendig oppsett |
| 69 | + # conftest.py (som nå ligger i /tests_directory) vil automatisk bli funnet av pytest |
113 | 70 | docker exec qgis-testing-environment sh -c "cd /tests_directory && xvfb-run pytest" |
114 | 71 |
|
115 | 72 | Check-code-quality: |
|
0 commit comments