@@ -153,6 +153,16 @@ def testGetOgrCompatibleSourceFromMemoryLayer(self):
153
153
self .assertTrue (res .isValid ())
154
154
self .assertEqual (res .featureCount (), 2 )
155
155
156
+ # with memory layers - if not executing layer source should be ignored and replaced
157
+ # with a dummy path, because:
158
+ # - it has no meaning for the gdal command outside of QGIS, memory layers don't exist!
159
+ # - we don't want to force an export of the whole memory layer to a temp file just to show the command preview
160
+ # this might be very slow!
161
+ ogr_data_path , ogr_layer_name = alg .getOgrCompatibleSource ('INPUT' , parameters , context , feedback ,
162
+ executing = False )
163
+ self .assertEqual (ogr_data_path , 'path_to_data_file' )
164
+ self .assertEqual (ogr_layer_name , 'layer_name' )
165
+
156
166
QgsProject .instance ().removeMapLayer (layer )
157
167
158
168
def testGetOgrCompatibleSourceFromOgrLayer (self ):
@@ -173,6 +183,12 @@ def testGetOgrCompatibleSourceFromOgrLayer(self):
173
183
path , layer = alg .getOgrCompatibleSource ('INPUT' , {'INPUT' : vl .id ()}, context , feedback , False )
174
184
self .assertEqual (path , source )
175
185
186
+ # with selected features only - if not executing, the 'selected features only' setting
187
+ # should be ignored (because it has no meaning for the gdal command outside of QGIS!)
188
+ parameters = {'INPUT' : QgsProcessingFeatureSourceDefinition (vl .id (), True )}
189
+ path , layer = alg .getOgrCompatibleSource ('INPUT' , parameters , context , feedback , False )
190
+ self .assertEqual (path , source )
191
+
176
192
def testGetOgrCompatibleSourceFromFeatureSource (self ):
177
193
# create a memory layer and add to project and context
178
194
layer = QgsVectorLayer ("Point?field=fldtxt:string&field=fldint:integer" ,
0 commit comments