MCPcopy
hub / github.com/django/django / test_collect

Method test_collect

tests/gis_tests/relatedapp/tests.py:302–325  ·  view source on GitHub ↗

Testing the `Collect` aggregate.

(self)

Source from the content-addressed store, hash-verified

300
301 @skipUnlessDBFeature("supports_collect_aggr")
302 def test_collect(self):
303 """
304 Testing the `Collect` aggregate.
305 """
306 # Reference query:
307 # SELECT AsText(ST_Collect("relatedapp_location"."point"))
308 # FROM "relatedapp_city"
309 # LEFT OUTER JOIN
310 # "relatedapp_location" ON (
311 # "relatedapp_city"."location_id" = "relatedapp_location"."id"
312 # )
313 # WHERE "relatedapp_city"."state" = 'TX';
314 ref_geom = GEOSGeometry(
315 "MULTIPOINT(-97.516111 33.058333,-96.801611 32.782057,"
316 "-95.363151 29.763374,-96.801611 32.782057)"
317 )
318
319 coll = City.objects.filter(state="TX").aggregate(Collect("location__point"))[
320 "location__point__collect"
321 ]
322 # Even though Dallas and Ft. Worth share same point, Collect doesn't
323 # consolidate -- that's why 4 points in MultiPoint.
324 self.assertEqual(4, len(coll))
325 self.assertTrue(ref_geom.equals(coll))
326
327 @skipUnlessDBFeature("supports_collect_aggr")
328 def test_collect_filter(self):

Callers

nothing calls this directly

Calls 5

GEOSGeometryClass · 0.90
CollectClass · 0.90
aggregateMethod · 0.80
filterMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected