def test_to_dict(self):
     condition = Condition('humidity', 'LESS_THAN', 10)
     instance = Alert('alert1', 'trigger1', [{
         "current_value": 263.576,
         "condition": condition.to_dict()}],
         {"lon": 37, "lat": 53},
         1481802090232)
     result = instance.to_dict()
     self.assertIsInstance(result, dict)
     self.assertEqual('alert1', result['id'])
     self.assertEqual('trigger1', result['trigger_id'])
     self.assertEqual(1, len(result['met_conditions']))
     mc = result['met_conditions'][0]
     self.assertEqual(dict(current_value=263.576, condition=condition.to_dict()), mc)
     self.assertEqual({"lon": 37, "lat": 53}, result['coordinates'])
     self.assertEqual(1481802090232, result['last_update'])
Esempio n. 2
0
 def test_to_dict(self):
     instance = Condition(WeatherParametersEnum.TEMPERATURE, OperatorsEnum.GREATER_THAN, 78.6, id='123456')
     result = instance.to_dict()
     self.assertIsInstance(result, dict)
     self.assertEqual('123456', result['id'])
     self.assertEqual(WeatherParametersEnum.TEMPERATURE, result['weather_param'])
     self.assertEqual(OperatorsEnum.GREATER_THAN, result['operator'])
     self.assertEqual(78.6, result['amount'])