Commit 80adb68c authored by Niklas Selke's avatar Niklas Selke
Browse files

modified the climatic zones service

parent 1466f9d8
Pipeline #97056 passed with stages
in 54 seconds
"""serializer for climate zones
"""serializer for climatic zones data
"""
from collections import OrderedDict
import datetime as dt
from utils.agg_serializer import GeneralAggSerializer
# serializer classes
class AggSerializer(GeneralAggSerializer):
......
from django.test import TestCase
from services.climatic_zones.serializers import AggSerializer
from services.climatic_zones.views import ClimateView
from services.climatic_zones.views import ClimaticZonesView
import geo_location_services.settings as settings
from collections import OrderedDict
......@@ -24,10 +24,9 @@ class TestSerializers(TestCase):
class TestViews(TestCase):
def test_ClimateView(self):
view = ClimateView()
self.assertEqual(view.min_valid, 1)
self.assertEqual(view.max_valid, 12)
def test_ClimaticZonesView(self):
view = ClimaticZonesView()
self.assertEqual(view.min_valid, 1.)
self.assertEqual(view.max_valid, 12.)
self.assertTrue(view.AggSerializer is AggSerializer)
self.assertListEqual(view.AGG_ALLOWED, ['maxclass', 'frequency'])
self.assertEqual(view.STATS["frequency"].keywords["bins"], 12)
self.assertListEqual(view.AGG_ALLOWED, [])
from django.urls import re_path
from .views import ClimateView
from .views import ClimaticZonesView
urlpatterns = [
re_path(r'^$', ClimateView.as_view()),
re_path(r'^$', ClimaticZonesView.as_view()),
]
......@@ -17,19 +17,16 @@ from utils.statistics import most_common_value, relative_frequency
# print("File %s successfully loaded" % FILENAME, datainfo)
class ClimateView(APIView, CommonViews):
class ClimaticZonesView(APIView, CommonViews):
def __init__(self):
opts = dict(default_value=0,
out_of_bounds_value=0,
min_valid=1,
max_valid=12,
opts = dict(default_value=0.,
out_of_bounds_value=0.,
min_valid=1.,
max_valid=12.,
serializer=AggSerializer,
service_type=Config.name)
CommonViews.__init__(self, **opts)
self.keep_only_given_agg_allowed(dict(maxclass=most_common_value,
frequency=relative_frequency),
frequency=dict(bins=12,
missing_value=self.default_value))
self.keep_only_given_agg_allowed({})
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