@@ -2225,6 +2225,142 @@ def testDescribeFeatureTypeWithInlineType(self):
22252225 got = got_f [0 ].geometry ().geometry ()
22262226 self .assertEqual ((got .x (), got .y ()), (2.0 , 49.0 ))
22272227
2228+ def testWFS20TransactionsDisabled (self ):
2229+ """Test WFS 2.0 Transaction disabled"""
2230+
2231+ endpoint = self .__class__ .basetestpath + '/fake_qgis_http_endpoint_WFS_2.0_transaction'
2232+
2233+ with open (sanitize (endpoint , '?SERVICE=WFS?REQUEST=GetCapabilities?ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0' ), 'wb' ) as f :
2234+ f .write ("""
2235+ <wfs:WFS_Capabilities version="2.0.0" xmlns="http://www.opengis.net/wfs/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://schemas.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0">
2236+ <ows:OperationsMetadata>
2237+ <ows:Operation name="GetFeature">
2238+ <ows:Constraint name="CountDefault">
2239+ <ows:NoValues/>
2240+ <ows:DefaultValue>1</ows:DefaultValue>
2241+ </ows:Constraint>
2242+ </ows:Operation>
2243+ <ows:Constraint name="ImplementsTransactionalWFS">
2244+ <ows:NoValues/>
2245+ <ows:DefaultValue>TRUE</ows:DefaultValue>
2246+ </ows:Constraint>
2247+ </ows:OperationsMetadata>
2248+ <FeatureTypeList>
2249+ <FeatureType>
2250+ <Name>my:typename</Name>
2251+ <Title>Title</Title>
2252+ <Abstract>Abstract</Abstract>
2253+ <DefaultCRS>urn:ogc:def:crs:EPSG::4326</DefaultCRS>
2254+ <ows:WGS84BoundingBox>
2255+ <ows:LowerCorner>-71.123 66.33</ows:LowerCorner>
2256+ <ows:UpperCorner>-65.32 78.3</ows:UpperCorner>
2257+ </ows:WGS84BoundingBox>
2258+ </FeatureType>
2259+ </FeatureTypeList>
2260+ </wfs:WFS_Capabilities>""" .encode ('UTF-8' ))
2261+
2262+ with open (sanitize (endpoint , '?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAME=my:typename' ), 'wb' ) as f :
2263+ f .write ("""
2264+ <xsd:schema xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://my">
2265+ <xsd:import namespace="http://www.opengis.net/gml/3.2"/>
2266+ <xsd:complexType name="typenameType">
2267+ <xsd:complexContent>
2268+ <xsd:extension base="gml:AbstractFeatureType">
2269+ <xsd:sequence>
2270+ <xsd:element maxOccurs="1" minOccurs="0" name="geometryProperty" nillable="true" type="gml:PointPropertyType"/>
2271+ </xsd:sequence>
2272+ </xsd:extension>
2273+ </xsd:complexContent>
2274+ </xsd:complexType>
2275+ <xsd:element name="typename" substitutionGroup="gml:_Feature" type="my:typenameType"/>
2276+ </xsd:schema>
2277+ """ .encode ('UTF-8' ))
2278+
2279+ # Create test layer
2280+ vl = QgsVectorLayer (u"url='http://" + endpoint + u"' typename='my:typename'" , u'test' , u'WFS' )
2281+ assert vl .isValid ()
2282+ self .assertEqual (vl .dataProvider ().capabilities () & vl .dataProvider ().EditingCapabilities , 0 )
2283+ self .assertEqual (vl .wkbType (), QgsWKBTypes .Point )
2284+
2285+ def testWFS20TransactionsEnabled (self ):
2286+ """Test WFS 2.0 Transaction enabled"""
2287+
2288+ endpoint = self .__class__ .basetestpath + '/fake_qgis_http_endpoint_WFS_2.0_transaction'
2289+
2290+ with open (sanitize (endpoint , '?SERVICE=WFS?REQUEST=GetCapabilities?ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0' ), 'wb' ) as f :
2291+ f .write ("""
2292+ <wfs:WFS_Capabilities version="2.0.0" xmlns="http://www.opengis.net/wfs/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://schemas.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0">
2293+ <ows:OperationsMetadata>
2294+ <ows:Operation name="GetFeature">
2295+ <ows:Constraint name="CountDefault">
2296+ <ows:NoValues/>
2297+ <ows:DefaultValue>1</ows:DefaultValue>
2298+ </ows:Constraint>
2299+ </ows:Operation>
2300+ <ows:Constraint name="ImplementsTransactionalWFS">
2301+ <ows:NoValues/>
2302+ <ows:DefaultValue>TRUE</ows:DefaultValue>
2303+ </ows:Constraint>
2304+ <ows:Operation name="Transaction">
2305+ <ows:DCP>
2306+ <ows:HTTP>
2307+ <ows:Get xlink:href="http://{endpoint}"/>
2308+ <ows:Post xlink:href="{endpoint}"/>
2309+ </ows:HTTP>
2310+ </ows:DCP>
2311+ <ows:Parameter name="inputFormat">
2312+ <ows:AllowedValues>
2313+ <ows:Value>text/xml; subtype=gml/3.2</ows:Value>
2314+ </ows:AllowedValues>
2315+ </ows:Parameter>
2316+ <ows:Parameter name="releaseAction">
2317+ <ows:AllowedValues>
2318+ <ows:Value>ALL</ows:Value>
2319+ <ows:Value>SOME</ows:Value>
2320+ </ows:AllowedValues>
2321+ </ows:Parameter>
2322+ </ows:Operation>
2323+ </ows:OperationsMetadata>
2324+ <FeatureTypeList>
2325+ <FeatureType>
2326+ <Name>my:typename</Name>
2327+ <Title>Title</Title>
2328+ <Abstract>Abstract</Abstract>
2329+ <DefaultCRS>urn:ogc:def:crs:EPSG::4326</DefaultCRS>
2330+ <ows:WGS84BoundingBox>
2331+ <ows:LowerCorner>-71.123 66.33</ows:LowerCorner>
2332+ <ows:UpperCorner>-65.32 78.3</ows:UpperCorner>
2333+ </ows:WGS84BoundingBox>
2334+ </FeatureType>
2335+ </FeatureTypeList>
2336+ </wfs:WFS_Capabilities>""" .format (endpoint = endpoint ).encode ('UTF-8' ))
2337+
2338+ with open (sanitize (endpoint , '?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAME=my:typename' ), 'wb' ) as f :
2339+ f .write ("""
2340+ <xsd:schema xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://my">
2341+ <xsd:import namespace="http://www.opengis.net/gml/3.2"/>
2342+ <xsd:complexType name="typenameType">
2343+ <xsd:complexContent>
2344+ <xsd:extension base="gml:AbstractFeatureType">
2345+ <xsd:sequence>
2346+ <xsd:element maxOccurs="1" minOccurs="0" name="intfield" nillable="true" type="xsd:int"/>
2347+ <xsd:element maxOccurs="1" minOccurs="0" name="longfield" nillable="true" type="xsd:long"/>
2348+ <xsd:element maxOccurs="1" minOccurs="0" name="stringfield" nillable="true" type="xsd:string"/>
2349+ <xsd:element maxOccurs="1" minOccurs="0" name="datetimefield" nillable="true" type="xsd:dateTime"/>
2350+ <xsd:element maxOccurs="1" minOccurs="0" name="geomfield" nillable="true" type="gml:PointPropertyType"/>
2351+ </xsd:sequence>
2352+ </xsd:extension>
2353+ </xsd:complexContent>
2354+ </xsd:complexType>
2355+ <xsd:element name="typename" substitutionGroup="gml:_Feature" type="my:typenameType"/>
2356+ </xsd:schema>
2357+ """ .encode ('UTF-8' ))
2358+
2359+ # Create test layer
2360+ vl = QgsVectorLayer (u"url='http://" + endpoint + u"' typename='my:typename'" , u'test' , u'WFS' )
2361+ assert vl .isValid ()
2362+ self .assertNotEqual (vl .dataProvider ().capabilities () & vl .dataProvider ().EditingCapabilities , 0 )
2363+ self .assertEqual (vl .wkbType (), QgsWKBTypes .Point )
22282364
22292365if __name__ == '__main__' :
22302366 unittest .main ()
0 commit comments