summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-01-28 07:44:55 -0500
committerTim Graham <timograham@gmail.com>2016-01-28 14:38:27 -0500
commit61452616baca63fa58efbb5991f65ba362eccbe2 (patch)
tree6ce5054dcab4fc45e45b20ab9f891af7a7b70aad
parent6103b4990025656a649caad641abb135941f6bf4 (diff)
[1.9.x] Fixed #26147 -- Relaxed expected values in GIS tests to account for database/library differences.
Backport of 5aa53286758fbb1fb864a5efda38718a2ca96759 from master
-rw-r--r--tests/gis_tests/distapp/tests.py4
-rw-r--r--tests/gis_tests/geogapp/tests.py16
2 files changed, 12 insertions, 8 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index ef9cc65a2e..20be91f437 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -146,7 +146,7 @@ class DistanceTest(TestCase):
"""
Test the `distance` GeoQuerySet method on geodetic coordinate systems.
"""
- tol = 2 if oracle else 5
+ tol = 2 if oracle else 4
# Testing geodetic distance calculation with a non-point geometry
# (a LineString of Wollongong and Shellharbour coords).
@@ -526,7 +526,7 @@ class DistanceFunctionsTests(TestCase):
@skipUnlessDBFeature("has_Distance_function", "supports_distance_geodetic")
def test_distance_geodetic_spheroid(self):
- tol = 2 if oracle else 5
+ tol = 2 if oracle else 4
# Got the reference distances using the raw SQL statements:
# SELECT ST_distance_spheroid(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326),
diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py
index 80afbd63c7..b99203afea 100644
--- a/tests/gis_tests/geogapp/tests.py
+++ b/tests/gis_tests/geogapp/tests.py
@@ -98,10 +98,12 @@ class GeographyTest(TestCase):
def test06_geography_area(self):
"Testing that Area calculations work on geography columns."
# SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';
- ref_area = 5439100.13586914 if oracle else 5439084.70637573
- tol = 5
z = Zipcode.objects.area().get(code='77002')
- self.assertAlmostEqual(z.area.sq_m, ref_area, tol)
+ # Round to the nearest thousand as possible values (depending on
+ # the database and geolib) include 5439084, 5439100, 5439101.
+ rounded_value = z.area.sq_m
+ rounded_value -= z.area.sq_m % 1000
+ self.assertEqual(rounded_value, 5439000)
@skipUnlessDBFeature("gis_enabled")
@@ -128,7 +130,9 @@ class GeographyFunctionTests(TestCase):
Testing that Area calculations work on geography columns.
"""
# SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';
- ref_area = 5439100.13587 if oracle else 5439084.70637573
- tol = 5
z = Zipcode.objects.annotate(area=Area('poly')).get(code='77002')
- self.assertAlmostEqual(z.area.sq_m, ref_area, tol)
+ # Round to the nearest thousand as possible values (depending on
+ # the database and geolib) include 5439084, 5439100, 5439101.
+ rounded_value = z.area.sq_m
+ rounded_value -= z.area.sq_m % 1000
+ self.assertEqual(rounded_value, 5439000)