Skip to content

Commit

Permalink
Merge pull request #12 from nansencenter/issue10-wrong-url
Browse files Browse the repository at this point in the history
Issue10 wrong url
  • Loading branch information
akorosov authored Jun 30, 2020
2 parents da66a35 + f0ee27b commit fa31ad0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 37 deletions.
21 changes: 14 additions & 7 deletions geospaas_adas_viewer/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json

from bs4 import BeautifulSoup
from django.test import Client, TestCase
from django.utils import timezone

from bs4 import BeautifulSoup
from geospaas.catalog.models import Dataset
from geospaas.vocabularies.models import Parameter
from geospaas_adas_viewer.views import AdasIndexView
Expand All @@ -15,15 +17,20 @@ def setUp(self):
self.client = Client()

def test_post_wrong_uri(self):
"""shall return the uri of fixtures' datasets in the specified placement
of datasets inside the resulted HTML in the case of a POST with a part of
parameter name inside the charfield of parameter in form """
res3 = self.client.post('/adas', {
""" Shall return 404 for wrong URL """
res = self.client.post('/adas', {
'time_coverage_start': timezone.datetime(2000, 12, 29),
'time_coverage_end': timezone.datetime(2020, 1, 1),
'source': 1,
'nameparameters': 'from_direction'}) # <= Notice the part of the name 'wind_from_direction' provided by user
self.assertEqual(res3.status_code, 404)
'nameparameters': 'from_direction'})
self.assertEqual(res.status_code, 404)

def test_get_geometry(self):
""" shall return GeoJSON geometry of the first dataset """
res = self.client.get('/geometry/1')
self.assertEqual(res.status_code, 200)
content = json.loads(res.content)
self.assertEqual(content['features'][0]['geometry']['type'], 'Polygon')

def test_the_post_verb_of_GUI_with_unique_part_of_parameter_name(self):
"""shall return the uri of fixtures' datasets in the specified placement
Expand Down
2 changes: 2 additions & 0 deletions geospaas_adas_viewer/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.urls import path
from geospaas_adas_viewer.views import AdasIndexView
from geospaas.base_viewer.views import get_geometry_geojson

app_name = 'geospaas_adas_viewer'
urlpatterns = [
path('', AdasIndexView.as_view(), name='adasindex'),
path('geometry/<int:pk>', get_geometry_geojson, name='geometry_geojson')
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import setuptools

setuptools.setup(name="geospaas_adas_viewer",
version="0.1.2",
version="0.1.3",
author=["Arash Azamifard", "Anton Korosov"],
description="ADAS viewer for GeoSPaaS",
url="https://github.com/nansencenter/django-geo-spaas-adas-viewer",
Expand Down
1 change: 1 addition & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@
STATICFILES_DIRS = [
"/project/static",
]
SERIALIZATION_MODULES = {"geojson": "django.contrib.gis.serializers.geojson",}
31 changes: 2 additions & 29 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
from django.conf.urls import include
from django.conf import settings
"""geospaas_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.urls import include, path

urlpatterns = [

#url(r'^', include('geospaas.urls')),
url('', include('geospaas_adas_viewer.urls')),

path('', include('geospaas_adas_viewer.urls')),
]
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import TemplateView
# Serve static and media files from development server
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0 comments on commit fa31ad0

Please sign in to comment.