Ejemplo n.º 1
0
def current(request):
    data = []
    locations = list(Location.objects.filter(user=request.user.id).all())
    for location in locations:
        weather_data = location.get_weather()
        weather_json = weather_data.to_json()
        weather_json['forecast'] = utils.get_forecast(location.location_name,
                                                      units=location.unit,
                                                      days=5, to_json=True)
        weather_json['city'] = location.location_name
        data.append(weather_json)
    return alfred_utils.render_to_json(request, data)
Ejemplo n.º 2
0
 def test_forecast(self, request_mock):
     request_mock.return_value = self.forecast_return
     forecast_now = utils.get_forecast("Oakland,CA", 'imperial', '2')
     self.assertEqual(self.expected_forecast, forecast_now[0].to_json())