MCPcopy
hub / github.com/django/django / test_extent

Method test_extent

tests/gis_tests/geoapp/tests.py:703–728  ·  view source on GitHub ↗

Testing the `Extent` aggregate.

(self)

Source from the content-addressed store, hash-verified

701
702 @skipUnlessDBFeature("supports_extent_aggr")
703 def test_extent(self):
704 """
705 Testing the `Extent` aggregate.
706 """
707 # Reference query:
708 # SELECT ST_extent(point)
709 # FROM geoapp_city
710 # WHERE (name='Houston' or name='Dallas');`
711 # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984
712 # 32.7820587158203)
713 expected = (
714 -96.8016128540039,
715 29.7633724212646,
716 -95.3631439208984,
717 32.782058715820,
718 )
719
720 qs = City.objects.filter(name__in=("Houston", "Dallas"))
721 extent = qs.aggregate(Extent("point"))["point__extent"]
722 for val, exp in zip(extent, expected):
723 self.assertAlmostEqual(exp, val, 4)
724 self.assertIsNone(
725 City.objects.filter(name=("Smalltown")).aggregate(Extent("point"))[
726 "point__extent"
727 ]
728 )
729
730 @skipUnlessDBFeature("supports_extent_aggr")
731 def test_extent_with_limit(self):

Callers

nothing calls this directly

Calls 3

ExtentClass · 0.90
aggregateMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected