MCPcopy
hub / github.com/django/django / test_geometryfield

Method test_geometryfield

tests/gis_tests/geoapp/tests.py:159–187  ·  view source on GitHub ↗

Testing the general GeometryField.

(self)

Source from the content-addressed store, hash-verified

157 self.assertIsNone(c.point)
158
159 def test_geometryfield(self):
160 "Testing the general GeometryField."
161 Feature(name="Point", geom=Point(1, 1)).save()
162 Feature(name="LineString", geom=LineString((0, 0), (1, 1), (5, 5))).save()
163 Feature(
164 name="Polygon",
165 geom=Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))),
166 ).save()
167 Feature(
168 name="GeometryCollection",
169 geom=GeometryCollection(
170 Point(2, 2),
171 LineString((0, 0), (2, 2)),
172 Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))),
173 ),
174 ).save()
175
176 f_1 = Feature.objects.get(name="Point")
177 self.assertIsInstance(f_1.geom, Point)
178 self.assertEqual((1.0, 1.0), f_1.geom.tuple)
179 f_2 = Feature.objects.get(name="LineString")
180 self.assertIsInstance(f_2.geom, LineString)
181 self.assertEqual(((0.0, 0.0), (1.0, 1.0), (5.0, 5.0)), f_2.geom.tuple)
182
183 f_3 = Feature.objects.get(name="Polygon")
184 self.assertIsInstance(f_3.geom, Polygon)
185 f_4 = Feature.objects.get(name="GeometryCollection")
186 self.assertIsInstance(f_4.geom, GeometryCollection)
187 self.assertEqual(f_3.geom, f_4.geom[2])
188
189 @skipUnlessDBFeature("supports_transform")
190 def test_inherited_geofields(self):

Callers

nothing calls this directly

Calls 8

PointClass · 0.90
LineStringClass · 0.90
PolygonClass · 0.90
LinearRingClass · 0.90
GeometryCollectionClass · 0.90
FeatureClass · 0.70
saveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected