Commit 3d7424c0 authored by Niklas Selke's avatar Niklas Selke
Browse files

modified the stable nightlights service

parent 84a08e83
Pipeline #97147 passed with stages
in 50 seconds
from django.apps import AppConfig
class StableNightLightsConfig(AppConfig): # pragma: no cover
class StableNightlightsConfig(AppConfig): # pragma: no cover
name = 'services.stable_nightlights'
"""serializer for stable night lights data
"""serializer for stable nightlights data
"""
from collections import OrderedDict
import datetime as dt
from utils.agg_serializer import GeneralAggSerializer
......
from django.test import TestCase
from services.stable_nightlights.serializers import AggSerializer
from services.stable_nightlights.views import NightTimeLightsView
from services.stable_nightlights.views import StableNightlightsView
import geo_location_services.settings as settings
from collections import OrderedDict
......@@ -18,17 +18,15 @@ class TestSerializers(TestCase):
('mean', 10),
])
serializer = AggSerializer(rawdata)
self.assertEqual(serializer.instance["unit"], '')
self.assertEqual(serializer.instance["unit"], "")
self.assertEqual(serializer.instance["radius"], 5000)
class TestViews(TestCase):
def test_NightTimeLightsView(self):
view = NightTimeLightsView()
self.assertEqual(view.min_valid, 0)
def test_StableNightlightsView(self):
view = StableNightlightsView()
self.assertEqual(view.min_valid, 0.)
self.assertEqual(view.max_valid, 2.e6)
self.assertTrue(view.AggSerializer is AggSerializer)
self.assertEqual(view.AGG_ALLOWED, ['mean', 'min', 'max', 'median', 'percentile', 'sum', 'stddev'])
self.assertEqual(view.service_type, "services.stable_nightlights")
from django.urls import re_path
from .views import NightTimeLightsView
from .views import StableNightlightsView
urlpatterns = [
re_path(r'^$', NightTimeLightsView.as_view()),
re_path(r'^$', StableNightlightsView.as_view()),
]
......@@ -3,7 +3,7 @@ from rest_framework.views import APIView
# from services.file_extractions.stable_nightlights_file_extraction import read_proxydata
from .serializers import AggSerializer
from utils.views_commons import CommonViewsWithYear
from .apps import StableNightLightsConfig as Config
from .apps import StableNightlightsConfig as Config
# if USE_LOCAL_DATA: # pragma: no cover
......@@ -13,16 +13,15 @@ from .apps import StableNightLightsConfig as Config
# print("File %s successfully loaded" % FILENAME, datainfo)
class NightTimeLightsView(APIView, CommonViewsWithYear):
class StableNightlightsView(APIView, CommonViewsWithYear):
def __init__(self):
opts = dict(default_value=-99.,
opts = dict(default_value=0.,
out_of_bounds_value=0.,
min_valid=0.,
max_valid=2.e6,
serializer=AggSerializer,
service_type=Config.name,
)
service_type=Config.name)
# providing `service_type` (and not `data`) will trigger a connection to Rasdaman
CommonViewsWithYear.__init__(self, **opts)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment