summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2016-12-16 08:36:16 +0500
committerTim Graham <timograham@gmail.com>2016-12-16 10:34:02 -0500
commit5d28fef8f9329e440ee67cefc900dbf89f4c524c (patch)
tree8878b3cd4337f462a597f247f20f8a3fdb69e606 /tests
parent3215bc98fe934f21f37fc5cc38ae5f123f444140 (diff)
Made NumPoints raise TypeError on MySQL when it's used on fields besides LineStringField.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geoapp/test_functions.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 023a6a087f..bbf1fd1144 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -304,11 +304,14 @@ class GISFunctionsTests(TestCase):
Track.objects.create(name='Foo', line=LineString(coords))
qs = Track.objects.annotate(num_points=functions.NumPoints('line'))
self.assertEqual(qs.first().num_points, 2)
- if spatialite or mysql:
- # SpatiaLite and MySQL can only count points on LineStrings
+ mpoly_qs = Country.objects.annotate(num_points=functions.NumPoints('mpoly'))
+ if not connection.features.supports_num_points_poly:
+ msg = 'NumPoints can only operate on LineString content on this database.'
+ with self.assertRaisesMessage(TypeError, msg):
+ list(mpoly_qs)
return
- for c in Country.objects.annotate(num_points=functions.NumPoints('mpoly')):
+ for c in mpoly_qs:
self.assertEqual(c.mpoly.num_points, c.num_points)
if not oracle: