mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Applied BoundingCircle test to only one country.
Looks like testing the second Country is much more computing-intensive and brings nothing to the test.
This commit is contained in:
parent
4114179ca7
commit
894fa55da1
@ -259,36 +259,31 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
|||||||
return (4 * num_seg) + 1
|
return (4 * num_seg) + 1
|
||||||
|
|
||||||
if connection.ops.postgis:
|
if connection.ops.postgis:
|
||||||
expected_areas = (169, 136)
|
expected_area = 169
|
||||||
elif connection.ops.spatialite:
|
elif connection.ops.spatialite:
|
||||||
expected_areas = (168, 135)
|
expected_area = 168
|
||||||
else: # Oracle.
|
else: # Oracle.
|
||||||
expected_areas = (171, 126)
|
expected_area = 171
|
||||||
qs = Country.objects.annotate(
|
country = Country.objects.annotate(
|
||||||
circle=functions.BoundingCircle("mpoly")
|
circle=functions.BoundingCircle("mpoly")
|
||||||
).order_by("name")
|
).order_by("name")[0]
|
||||||
self.assertAlmostEqual(qs[0].circle.area, expected_areas[0], 0)
|
self.assertAlmostEqual(country.circle.area, expected_area, 0)
|
||||||
self.assertAlmostEqual(qs[1].circle.area, expected_areas[1], 0)
|
|
||||||
if connection.ops.postgis:
|
if connection.ops.postgis:
|
||||||
# By default num_seg=48.
|
# By default num_seg=48.
|
||||||
self.assertEqual(qs[0].circle.num_points, circle_num_points(48))
|
self.assertEqual(country.circle.num_points, circle_num_points(48))
|
||||||
self.assertEqual(qs[1].circle.num_points, circle_num_points(48))
|
|
||||||
|
|
||||||
tests = [12, Value(12, output_field=IntegerField())]
|
tests = [12, Value(12, output_field=IntegerField())]
|
||||||
for num_seq in tests:
|
for num_seq in tests:
|
||||||
with self.subTest(num_seq=num_seq):
|
with self.subTest(num_seq=num_seq):
|
||||||
qs = Country.objects.annotate(
|
country = Country.objects.annotate(
|
||||||
circle=functions.BoundingCircle("mpoly", num_seg=num_seq),
|
circle=functions.BoundingCircle("mpoly", num_seg=num_seq),
|
||||||
).order_by("name")
|
).order_by("name")[0]
|
||||||
if connection.ops.postgis:
|
if connection.ops.postgis:
|
||||||
self.assertGreater(qs[0].circle.area, 168.4, 0)
|
self.assertGreater(country.circle.area, 168.4, 0)
|
||||||
self.assertLess(qs[0].circle.area, 169.5, 0)
|
self.assertLess(country.circle.area, 169.5, 0)
|
||||||
self.assertAlmostEqual(qs[1].circle.area, 136, 0)
|
self.assertEqual(country.circle.num_points, circle_num_points(12))
|
||||||
self.assertEqual(qs[0].circle.num_points, circle_num_points(12))
|
|
||||||
self.assertEqual(qs[1].circle.num_points, circle_num_points(12))
|
|
||||||
else:
|
else:
|
||||||
self.assertAlmostEqual(qs[0].circle.area, expected_areas[0], 0)
|
self.assertAlmostEqual(country.circle.area, expected_area, 0)
|
||||||
self.assertAlmostEqual(qs[1].circle.area, expected_areas[1], 0)
|
|
||||||
|
|
||||||
@skipUnlessDBFeature("has_Centroid_function")
|
@skipUnlessDBFeature("has_Centroid_function")
|
||||||
def test_centroid(self):
|
def test_centroid(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user