summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-03-20 12:10:29 +0500
committerTim Graham <timograham@gmail.com>2017-03-23 20:06:16 -0400
commit1b1ea63f6a4784e213c059c69beccaea20bc1a92 (patch)
tree1eb5ea81c715e0bb198ff116ee329a11411144ca /tests
parente9149d3eb0ed0ddc8b27b1990eb2b7293c1231cd (diff)
Fixed #27962 -- Allowed lookups on Area annotations.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geoapp/test_functions.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 9896aff5c3..21b0c283e4 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -264,6 +264,19 @@ class GISFunctionsTests(TestCase):
result = result.sq_m
self.assertAlmostEqual((result - c.mpoly.area) / c.mpoly.area, 0)
+ @skipUnlessDBFeature("has_Area_function")
+ def test_area_lookups(self):
+ # Create projected countries so the test works on all backends.
+ CountryWebMercator.objects.bulk_create(
+ CountryWebMercator(name=c.name, mpoly=c.mpoly.transform(3857, clone=True))
+ for c in Country.objects.all()
+ )
+ qs = CountryWebMercator.objects.annotate(area=functions.Area('mpoly'))
+ self.assertEqual(qs.get(area__lt=Area(sq_km=500000)), CountryWebMercator.objects.get(name='New Zealand'))
+
+ with self.assertRaisesMessage(ValueError, 'AreaField only accepts Area measurement objects.'):
+ qs.get(area__lt=500000)
+
@skipUnlessDBFeature("has_MakeValid_function")
def test_make_valid(self):
invalid_geom = fromstr('POLYGON((0 0, 0 1, 1 1, 1 0, 1 1, 1 0, 0 0))')