Skip to content

Commit 248040d

Browse files
fix: use correct strati table
1 parent 3b61ed6 commit 248040d

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎tests/qgis/test_basal_contacts.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from pathlib import Path
3-
from qgis.core import QgsVectorLayer, QgsProcessingContext, QgsProcessingFeedback, QgsMessageLog, Qgis, QgsApplication
3+
from qgis.core import QgsVectorLayer, QgsProcessingContext, QgsProcessingFeedback, QgsMessageLog, Qgis, QgsApplication, QgsFeature, QgsField
4+
from qgis.PyQt.QtCore import QVariant
45
from qgis.testing import start_app
56
from m2l.processing.algorithms.extract_basal_contacts import BasalContactsAlgorithm
67
from m2l.processing.provider import Map2LoopProvider
@@ -61,7 +62,23 @@ def test_basal_contacts_extraction(self):
6162
"Rocklea Inlier greenstones",
6263
"Rocklea Inlier metagranitic unit"
6364
]
65+
strati_table = QgsVectorLayer(faults_layer.crs().authid(), "strati_column", "memory")
66+
# define the single field
67+
provider = strati_table.dataProvider()
68+
provider.addAttributes([QgsField("unit_name", vtype)])
69+
strati_table.updateFields()
70+
vtype=QVariant.String
71+
# add features (one row per value)
72+
feats = []
73+
fields = strati_table.fields()
74+
for val in strati_column:
75+
f = QgsFeature(fields)
76+
f.setAttributes([val])
77+
feats.append(f)
6478

79+
if feats:
80+
provider.addFeatures(feats)
81+
strati_table.updateExtents()
6582
algorithm = BasalContactsAlgorithm()
6683
algorithm.initAlgorithm()
6784

@@ -70,7 +87,7 @@ def test_basal_contacts_extraction(self):
7087
'UNIT_NAME_FIELD': 'unitname',
7188
'FORMATION_FIELD': 'formation',
7289
'FAULTS': faults_layer,
73-
'STRATIGRAPHIC_COLUMN': strati_column,
90+
'STRATIGRAPHIC_COLUMN': strati_table,
7491
'IGNORE_UNITS': [],
7592
'BASAL_CONTACTS': 'memory:basal_contacts',
7693
'ALL_CONTACTS': 'memory:all_contacts'

0 commit comments

Comments
 (0)