From d013134ffb1e03cefa6ab0d987b72ac9231580d7 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Thu, 15 Dec 2016 22:15:08 +0500 Subject: [PATCH] Improved testing of num_seg kwarg of BoundingCircle GIS function. --- tests/gis_tests/geoapp/test_functions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index a2c172b001..3ce72b9d21 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -147,16 +147,25 @@ class GISFunctionsTests(TestCase): @skipUnlessDBFeature("has_BoundingCircle_function") def test_bounding_circle(self): + def circle_num_points(num_seg): + # num_seg is the number of segments per quarter circle. + return (4 * num_seg) + 1 + # The weak precision in the assertions is because the BoundingCircle # calculation changed on PostGIS 2.3. qs = Country.objects.annotate(circle=functions.BoundingCircle('mpoly')).order_by('name') self.assertAlmostEqual(qs[0].circle.area, 169, 0) self.assertAlmostEqual(qs[1].circle.area, 136, 0) + # By default num_seg=48. + self.assertEqual(qs[0].circle.num_points, circle_num_points(48)) + self.assertEqual(qs[1].circle.num_points, circle_num_points(48)) qs = Country.objects.annotate(circle=functions.BoundingCircle('mpoly', num_seg=12)).order_by('name') self.assertGreater(qs[0].circle.area, 168.4, 0) self.assertLess(qs[0].circle.area, 169.5, 0) self.assertAlmostEqual(qs[1].circle.area, 136, 0) + self.assertEqual(qs[0].circle.num_points, circle_num_points(12)) + self.assertEqual(qs[1].circle.num_points, circle_num_points(12)) @skipUnlessDBFeature("has_Centroid_function") def test_centroid(self):