Testing the `Collect` aggregate.
(self)
| 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): |
nothing calls this directly
no test coverage detected