Exemplo n.º 1
0
 def test_get_all_locations_not_in_good_or_bad_weather(self):
     good_weather = WeatherFactory(temperature_today=60, temperature_tomorrow=55)
     poor_weather = WeatherFactory(temperature_today=50, temperature_tomorrow=55)
     good = [good_weather.location]
     poor = [poor_weather.location]
     expected = [l for l in Location.objects.all() if l not in good and l not in poor]
     ret = get_all_other_cities(good, poor)
     self.assertEqual(ret, expected)
Exemplo n.º 2
0
 def test_sends_backup_email_if_missing_data(self, patch_get_con,
                                             patch_get_weather,
                                             patch_send_backup):
     sub = SubscriberFactory()
     [WeatherFactory(location=l) for l in Location.objects.all()]
     patch_get_weather.side_effect = KeyError
     send_city_mail(sub.location, 'subject', 'connection')
     assert patch_send_backup.called
Exemplo n.º 3
0
 def test_only_sends_users_for_city(self, patch_get_con, patch_get_weather,
                                    patch_send_msg, patch_email_body):
     sub = SubscriberFactory()
     [SubscriberFactory() for i in range(5)]
     [WeatherFactory(location=l) for l in Location.objects.all()]
     send_city_mail(sub.location, 'subject', 'connection')
     patch_send_msg.assert_called_with('subject', patch_email_body.format(),
                                       sub.email, 'connection')
Exemplo n.º 4
0
 def test_sunny(self):
     w = WeatherFactory(temperature_today=55, temperature_tomorrow=55, weather_code=800)
     expected = [w.location]
     ret = get_cities_with_good_weather()
     self.assertEqual(ret, expected)
Exemplo n.º 5
0
 def test_five_degrees_warmer_than_tomorrow(self):
     w = WeatherFactory(temperature_today=60, temperature_tomorrow=55)
     expected = [w.location]
     ret = get_cities_with_good_weather()
     self.assertEqual(ret, expected)
Exemplo n.º 6
0
 def test_dont_choose_users_in_good_weather(self):
     w = WeatherFactory(temperature_today=60, temperature_tomorrow=55, weather_code=800)
     good_weather = [w.location]
     expected = []
     ret = get_cities_with_crummy_weather(good_weather)
     self.assertEqual(ret, expected)
Exemplo n.º 7
0
 def test_precipitating(self):
     w = WeatherFactory(temperature_today=55, temperature_tomorrow=55, weather_code=700)
     good_weather = []
     expected = [w.location]
     ret = get_cities_with_crummy_weather(good_weather)
     self.assertEqual(ret, expected)
Exemplo n.º 8
0
 def test_five_degrees_cooler_than_tomorrow(self):
     w = WeatherFactory(temperature_today=50, temperature_tomorrow=55, weather_code=800)
     good_weather = []
     expected = [w.location]
     ret = get_cities_with_crummy_weather(good_weather)
     self.assertEqual(ret, expected)