summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-09-28 20:55:21 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-10-24 09:06:27 +0200
commitef28b05767482bf9c98acc19ffd1334f75165b5a (patch)
treed28d9828d4d11917f28c5b62845ec87f157a2a15 /tests/gis_tests
parentde2bb73904009313bae3664ef71edfd60df9912b (diff)
Refs #35803 -- Added more tests for __coveredby and __covers GIS lookups.
Co-authored-by: David Smith <smithdc@gmail.com>
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/geoapp/tests.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 7ee47ee9a8..962d4f2217 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -496,6 +496,42 @@ class GeoLookupTest(TestCase):
with self.assertNoLogs("django.contrib.gis", "ERROR"):
State.objects.filter(poly__intersects="LINESTRING(0 0, 1 1, 5 5)")
+ @skipUnlessGISLookup("coveredby")
+ def test_coveredby_lookup(self):
+ poly = Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)))
+ state = State.objects.create(name="Test", poly=poly)
+
+ small_poly = Polygon(LinearRing((0, 0), (1, 4), (4, 4), (4, 1), (0, 0)))
+ qs = State.objects.filter(poly__coveredby=small_poly)
+ self.assertSequenceEqual(qs, [])
+
+ large_poly = Polygon(LinearRing((0, 0), (-1, 6), (6, 6), (6, -1), (0, 0)))
+ qs = State.objects.filter(poly__coveredby=large_poly)
+ self.assertSequenceEqual(qs, [state])
+
+ if not connection.ops.oracle:
+ # On Oracle, COVEREDBY doesn't match for EQUAL objects.
+ qs = State.objects.filter(poly__coveredby=poly)
+ self.assertSequenceEqual(qs, [state])
+
+ @skipUnlessGISLookup("covers")
+ def test_covers_lookup(self):
+ poly = Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)))
+ state = State.objects.create(name="Test", poly=poly)
+
+ small_poly = Polygon(LinearRing((0, 0), (1, 4), (4, 4), (4, 1), (0, 0)))
+ qs = State.objects.filter(poly__covers=small_poly)
+ self.assertSequenceEqual(qs, [state])
+
+ large_poly = Polygon(LinearRing((-1, -1), (-1, 6), (6, 6), (6, -1), (-1, -1)))
+ qs = State.objects.filter(poly__covers=large_poly)
+ self.assertSequenceEqual(qs, [])
+
+ if not connection.ops.oracle:
+ # On Oracle, COVERS doesn't match for EQUAL objects.
+ qs = State.objects.filter(poly__covers=poly)
+ self.assertSequenceEqual(qs, [state])
+
@skipUnlessDBFeature("supports_relate_lookup")
def test_relate_lookup(self):
"Testing the 'relate' lookup type."