Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue126 remove geospaas urls #153

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
6 changes: 0 additions & 6 deletions docs/source/geospaas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ geospaas.models module
:undoc-members:
:show-inheritance:

geospaas.urls module
--------------------

.. automodule:: geospaas.urls
:members:
:undoc-members:
:show-inheritance:


Module contents
Expand Down
9 changes: 5 additions & 4 deletions geospaas/catalog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,17 @@ def test_unique_constraint_geographic_location(self):
with self.assertRaises(django.db.utils.IntegrityError):
geolocation2.save()

def test__reproduce__not_null_constraint_failed(self):
def test_GeographicLocation_object_creation_and_uniqueness(self):
"""Test that GeographicLocation object can be created with high and low precision of
numbers (db can handle both cases). In addition, the same GeographicLocation can't
be created twice"""
geom_wkt = 'POLYGON((1.9952502916543926 43.079137301616434,1.8083614437225106 43.110281163194,1.6280391132319614 43.13999933989308,1.4543047771860391 43.168322409488,1.287178802518546 43.19527992537942,1.126680477150093 43.22090040126175,0.9728280404789855 43.24521129666272,0.8256387132257121 43.26823900332679,0.6851287265540695 43.2900088324148,0.5513133503959514 43.31054500249216,0.4177032107533156 43.3308546554019,0.4177032107533156 43.3308546554019,0.31209072545607186 42.966172534807384,0.2072770834059167 42.60138984322352,0.10324224766647609 42.23651548835664,-3.327518831779395e-05 41.87155835974214,-0.10256845388361147 41.50652732885059,-0.20438175048840848 41.14143124914533,-0.305491137731497 40.776278956093606,-0.4059141156224018 40.4110792671334,-0.5056677274094622 40.045840981598744,-0.6188735003262834 39.62838980058282,-0.6188735003262834 39.62838980058282,-0.4938090620192412 39.60834071737128,-0.36846516623385345 39.58812662484392,-0.2367679070115216 39.566753658618175,-0.09872965092928164 39.54419980869909,0.045636463325510676 39.520442055142105,0.19631650129236156 39.49545637806485,0.35329570832956364 39.469217768317954,0.516558484513175 39.441700238839005,0.686088358898322 39.412876836714965,0.8618679632011015 39.382719655976956,0.8618679632011015 39.382719655976956,0.985334472893415 39.799577386800905,1.0941941665822539 40.164279112775866,1.2038450353475123 40.52892574316672,1.3143064728956748 40.89350812553239,1.425598388091744 41.25801708090206,1.5377412226553768 41.622443403572326,1.6507559695776892 41.98677786085107,1.764664192292795 42.351011192745254,1.8794880446399878 42.71513411159017,1.9952502916543926 43.079137301616434))'
with self.assertRaises(django.db.utils.IntegrityError):
gg, created = GeographicLocation.objects.get_or_create(geometry=WKTReader().read(geom_wkt))
gg, created = GeographicLocation.objects.get_or_create(geometry=WKTReader().read(geom_wkt))
Comment on lines -179 to +181
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the error due to max precision does not happen anymore, this test can probably be deleted.

Or maybe it still happens with a particular database backend?
Even if it is the case, I am not sure if we should keep that test, since it does not validate a desired behavior.
Maybe it would be more relevant to create an issue about this problem, describing steps to reproduce it.

Any thoughts about that @akorosov, @mortenwh ?

Copy link
Member

@akorosov akorosov Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this error myself. However the test can remain here.
What's needed:

  • rename the test to reflect that not_null_constraint_failed is not reproduced anymore
  • add a relevant comment that db actually can handle high precision numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 04899cf

geom_wkt = 'POLYGON((1.995 43.079,1.808 43.1102,1.628 43.139,1.454 43.168,1.287 43.195,1.126 43.220,0.972 43.245,0.825 43.268,0.685 43.290,0.551 43.310,0.417 43.330,0.417 43.330,0.312 42.966,0.207 42.601,0.103 42.236,0.0 41.871,-0.102 41.506,-0.204 41.141,-0.305 40.776,-0.405 40.411,-0.505 40.045,-0.618 39.628,-0.618 39.628,-0.493 39.608,-0.368 39.588,-0.236 39.566,-0.098 39.544,0.0456 39.520,0.196 39.495,0.353 39.469,0.516 39.441,0.686 39.412,0.861 39.382,0.861 39.382,0.985 39.799,1.094 40.164,1.203 40.528,1.314 40.893,1.425 41.258,1.537 41.622,1.650 41.986,1.764 42.351,1.879 42.715,1.995 43.079))'
gg, created = GeographicLocation.objects.get_or_create(geometry=WKTReader().read(geom_wkt))
self.assertTrue(created)
gg, created = GeographicLocation.objects.get_or_create(geometry=WKTReader().read(geom_wkt))
self.assertFalse(created)
# Conclusion: db can't handle numbers with too many decimals (NOT NULL constraint failed)


class PersonnelTests(TestCase):
Expand Down
9 changes: 4 additions & 5 deletions geospaas/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
from geospaas.utils import utils

class TestUtils(TestCase):

def test_validate_uri_opendap_does_not_exist(self):
uri = 'http://www.ifremer.fr/opendap/cerdap1/globcurrent/' \
'v2.0/global_012_deg/geostrophic/2014/001/' \
'20140101000000-GLOBCURRENT-L4-CURgeo_0m-ALT_OI-v02.0-fv01.0.nc.tull'
@patch('urllib3.PoolManager')
def test_validate_uri_opendap_does_not_exist(self, mock_PoolManager):
uri = 'http://www.ifremer.fr'
mock_PoolManager.status=1
with self.assertRaises(OSError) as cm:
utils.validate_uri(uri)
self.assertEqual('NetCDF: file not found', cm.exception.args[1])
Expand Down
12 changes: 0 additions & 12 deletions geospaas/urls.py

This file was deleted.

2 changes: 1 addition & 1 deletion provisioning/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- django_forms_bootstrap
- leaflet
django_urlpatterns:
- "path('', include('geospaas.urls')),"
- "path('', include('geospaas.base_viewer.urls')),"

- role: geospaas
geospaas_project_home: '{{ project_home }}'
Expand Down