Example #1
0
 def test_loop_all_hist(self):
     
     #Prep the DB for Pittsburgh
     loc_loader = LocationLoader()
     loc_loader.save_data_city('Pittsburgh,pa')
     
     #prep timeframe variables
     load  = LocationLoaderHist()
     pitt = Location.objects.get(city_name='Pittsburgh')
     startb = datetime.datetime.now() + datetime.timedelta(-30)
     
     end_unaware = datetime.datetime.now() + datetime.timedelta(-1)
     end = end_unaware.replace(tzinfo=pytz.UTC)
     
     #clear out conflicting data
     pitt.temperature_set.all().delete()
     pitt.windspeed_set.all().delete()
     
     load.loop_all_hist('Pittsburgh',startb)
     
     #validate
     wind_max_dict = pitt.windspeed_set.all().aggregate(Max('timestamp'))
     temp_max_dict = pitt.temperature_set.all().aggregate(Max('timestamp')) 
     
     wind_max = wind_max_dict['timestamp__max']
     temp_max = temp_max_dict['timestamp__max']
     
     
     self.assertTrue( (wind_max - end) <= datetime.timedelta(days = 1))
     self.assertTrue( (temp_max - end) <= datetime.timedelta(days = 1))
Example #2
0
 def test_get_open_weather_city_hist_imperial(self):
     print('Validate successful call of IMPERIAL weather data by city')
     loc_loader = LocationLoaderHist()
     start_date_test = datetime.datetime.now() + datetime.timedelta(-30)
     data = loc_loader.get_open_weather_city_hist_imperial('5367929', start_date_test)
     print('Data Received from API Call-------------------')
     print(data)
     self.assertEqual(len(data[u'list']), data[u'cnt'])