Commit 84a08e83 authored by Niklas Selke's avatar Niklas Selke
Browse files

modified the population number service

parent 46c66b42
Pipeline #97132 passed with stages
in 50 seconds
from django.apps import AppConfig
class PopulationDensityConfig(AppConfig): # pragma: no cover
name = 'services.population_density'
"""serializer for population density data
"""
from utils.agg_serializer import GeneralAggSerializer
# serializer classes
class AggSerializer(GeneralAggSerializer):
def __init__(self, instance):
instance['unit'] = '1/km^2'
super(AggSerializer, self).__init__(instance)
"""serializer for population number data
"""
from collections import OrderedDict
import datetime as dt
from utils.agg_serializer import GeneralAggSerializer
......
......@@ -18,7 +18,7 @@ class TestSerializers(TestCase):
('mean', 10),
])
serializer = AggSerializer(rawdata)
self.assertEqual(serializer.instance["unit"], '')
self.assertEqual(serializer.instance["unit"], "")
self.assertEqual(serializer.instance["radius"], 5000)
......@@ -26,9 +26,7 @@ class TestViews(TestCase):
def test_PopulationNumberView(self):
view = PopulationNumberView()
self.assertEqual(view.min_valid, 0)
self.assertEqual(view.min_valid, 0.)
self.assertEqual(view.max_valid, 2.e9)
self.assertTrue(view.AggSerializer is AggSerializer)
self.assertListEqual(view.AGG_ALLOWED, ['mean', 'min', 'max', 'median', 'percentile', 'sum', 'stddev'])
self.assertEqual(view.service_type, "services.population_number")
......@@ -17,7 +17,9 @@ class PopulationNumberView(APIView, CommonViewsWithYear):
def __init__(self):
opts = dict(min_valid=0,
opts = dict(default_value=0.,
out_of_bounds_value=0.,
min_valid=0.,
max_valid=2.e9,
serializer=AggSerializer,
service_type=Config.name)
......
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