def test_weather_view_lat_long(self, requests): # Setup scenario payload = {'results': [{'geometry': {'location': {'lat': 35.0357569, 'lng': -85.3197919}}}]} latitude = 35.0357569 longitude = -85.3197919 requests.get.return_value.json.return_value = payload # Verify expectation self.assertEqual(lat_long_lookup(37403), (latitude, longitude))
def get(self, request, *args, **kwargs): location = request.GET['text'] user = request.GET['user_name'] responses = [ 'The answer lies in your heart', 'I do not know', 'You spelt weather wrong', 'Nope', 'Shh, I am trying to sleep', 'Why do you need to ask?', 'Go away. I do not wish to answer at this time.', 'The window is 5 feet away. Stop being lazy', 'Just Goolge it'] if user == 'jeff.mcriffey': weather = random.choice(responses) elif location == '': lat_long = lat_long_lookup('37403') weather = weather_summary(lat_long) else: lat_long = lat_long_lookup(location) weather = weather_summary(lat_long) return HttpResponse(weather)