MCPcopy
hub / github.com/django/django / test_cast_aggregate

Method test_cast_aggregate

tests/gis_tests/geogapp/tests.py:122–139  ·  view source on GitHub ↗

Cast a geography to a geometry field for an aggregate function that expects a geometry input.

(self)

Source from the content-addressed store, hash-verified

120
121 @skipUnlessDBFeature("supports_extent_aggr")
122 def test_cast_aggregate(self):
123 """
124 Cast a geography to a geometry field for an aggregate function that
125 expects a geometry input.
126 """
127 if not connection.features.supports_geography:
128 self.skipTest("This test needs geography support")
129 expected = (
130 -96.8016128540039,
131 29.7633724212646,
132 -95.3631439208984,
133 32.782058715820,
134 )
135 res = City.objects.filter(name__in=("Houston", "Dallas")).aggregate(
136 extent=models.Extent(Cast("point", models.PointField()))
137 )
138 for val, exp in zip(res["extent"], expected):
139 self.assertAlmostEqual(exp, val, 4)
140
141 @skipUnlessDBFeature("has_Distance_function", "supports_distance_geodetic")
142 def test_distance_function(self):

Callers

nothing calls this directly

Calls 3

CastClass · 0.90
aggregateMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected