MCPcopy
hub / github.com/django/django / test_asgml

Method test_asgml

tests/gis_tests/geoapp/test_functions.py:160–190  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

158
159 @skipUnlessDBFeature("has_AsGML_function")
160 def test_asgml(self):
161 # Should throw a TypeError when trying to obtain GML from a
162 # non-geometry field.
163 qs = City.objects.all()
164 with self.assertRaises(TypeError):
165 qs.annotate(gml=functions.AsGML("name"))
166 ptown = City.objects.annotate(gml=functions.AsGML("point", precision=9)).get(
167 name="Pueblo"
168 )
169
170 if connection.ops.oracle:
171 # No precision parameter for Oracle :-/
172 gml_regex = re.compile(
173 r'^<gml:Point srsName="EPSG:4326" '
174 r'xmlns:gml="http://www.opengis.net/gml">'
175 r'<gml:coordinates decimal="\." cs="," ts=" ">'
176 r"-104.60925\d+,38.25500\d+ "
177 r"</gml:coordinates></gml:Point>"
178 )
179 else:
180 gml_regex = re.compile(
181 r'^<gml:Point srsName="(urn:ogc:def:crs:)?EPSG:4326"><gml:coordinates>'
182 r"-104\.60925\d+,38\.255001</gml:coordinates></gml:Point>"
183 )
184 self.assertTrue(gml_regex.match(ptown.gml))
185 self.assertIn(
186 '<gml:pos srsDimension="2">',
187 City.objects.annotate(gml=functions.AsGML("point", version=3))
188 .get(name="Pueblo")
189 .gml,
190 )
191
192 @skipUnlessDBFeature("has_AsKML_function")
193 def test_askml(self):

Callers

nothing calls this directly

Calls 5

annotateMethod · 0.80
allMethod · 0.45
getMethod · 0.45
compileMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected