Esempio n. 1
0
    def test_parse_observation(self):

        obs = get_observations(self.obs_xml)
        obs1 = obs[0]

        obs_info, raw_data = parse_observation(obs1)

        expected = {'sampling_time':
                    ['2015-03-27T01:00:00.000+01:00',
                     '2015-03-27T11:00:00.000+01:00'],
                    'feature_of_interest':
                    {'description': 'suburban - Industrial',
                     'id': 'BETM705',
                     'long_name': '44M705 - ROESELARE',
                     'name': '44M705'}}
        self.assertDictEqual(obs_info, expected)

        raw_data_expected = '2015-03-27T01:00:00.000+01:00,67.5;2015-03-27T02:00:00.000+01:00,65.5;2015-03-27T03:00:00.000+01:00,64.5;2015-03-27T04:00:00.000+01:00,65.0;2015-03-27T05:00:00.000+01:00,62.5;2015-03-27T06:00:00.000+01:00,57.0;2015-03-27T07:00:00.000+01:00,32.5;2015-03-27T08:00:00.000+01:00,25.0;2015-03-27T09:00:00.000+01:00,37.5;2015-03-27T10:00:00.000+01:00,59.0;2015-03-27T11:00:00.000+01:00,65.5;'
        self.assertEqual(raw_data, raw_data_expected)
    def test_query_and_parse(self):

        # small test example
        pollutant = 'o3'
        station = 'BETN060'
        period1 = '2015-03-27T00:00:00'
        period2 = '2015-03-27T10:00:00'
        response = query_ircelsos(pollutant, station, period1, period2)
        observations = get_observations(response)
        obs_info, raw_data = parse_observation(observations[0])

        obs_info_expected = {'sampling_time':
                             ['2015-03-27T01:00:00.000+01:00',
                              '2015-03-27T11:00:00.000+01:00'],
                             'feature_of_interest':
                             {'description': 'unknown - Unknown',
                              'id': 'BETN060',
                              'long_name': '43N060 - HAVINNES',
                              'name': '43N060'}}
        self.assertDictEqual(obs_info, obs_info_expected)

        raw_data_expected = '2015-03-27T01:00:00.000+01:00,48.0;2015-03-27T02:00:00.000+01:00,51.0;2015-03-27T03:00:00.000+01:00,52.0;2015-03-27T04:00:00.000+01:00,47.5;2015-03-27T05:00:00.000+01:00,45.0;2015-03-27T06:00:00.000+01:00,40.5;2015-03-27T07:00:00.000+01:00,25.0;2015-03-27T08:00:00.000+01:00,17.0;2015-03-27T09:00:00.000+01:00,23.0;2015-03-27T10:00:00.000+01:00,42.5;2015-03-27T11:00:00.000+01:00,49.0;'
        self.assertEqual(raw_data, raw_data_expected)