Пример #1
0
 def test_valid_data(self):
     ret = parse_hydrodata(self.mock_data)[0]
     self.assertEqual(ret["key"], self.mock_parsed_data[0]["key"])
     self.assertEqual(ret["name"], self.mock_parsed_data[0]["name"])
     self.assertEqual(ret["date"], self.mock_parsed_data[0]["date"])
     self.assertEqual(ret["time"], self.mock_parsed_data[0]["time"])
     self.assertAlmostEqual(ret["time_mili"],
                            self.mock_parsed_data[0]["time_mili"],
                            delta=100000000)
     self.assertEqual(ret["value"], self.mock_parsed_data[0]["value"])
 def test_valid_missing_timemilli(self):
     start_date = "2008-05-20"
     start_time = "00:00:00"
     dt = datetime.strptime(start_date + ' ' + start_time,
                            '%Y-%m-%d %H:%M:%S')
     dt_ms = time.mktime(dt.timetuple()) * 1000
     ret = parse_hydrodata(self.mock_data_missing_points)
     for dp in ret:
         self.assertAlmostEqual(dt_ms, dp['time_mili'])
         dt_ms += 900000
Пример #3
0
 def test_data_not_list(self):
     self.assertEqual(parse_hydrodata({}), [])
Пример #4
0
 def test_empty_data(self):
     self.assertEqual(parse_hydrodata([]), [])
     self.assertEqual(parse_hydrodata(None), [])
 def test_valid_data_missing_value(self):
     ret = parse_hydrodata(self.mock_data_missing_points)
     self.assertEqual(ret[3]['value'], 'NA')
 def test_valid_data_missing_count(self):
     ret = parse_hydrodata(self.mock_data_missing_points)
     self.assertEqual(len(ret), len(self.mock_parsed_data_missing))