Example #1
0
 def setUp(self):
     self.food_taste = FoodTaste()
     self.food_taste.preferences({
         'item1': 1,
         'item2': 2,
         'item3': 3,
         'item4': 4,
         'item5': 5,
         'item6_part1 item6_part2': 6
     })
 def setUp(self):
     self.cafes = copy.deepcopy(CAFES)
     self.taste = FoodTaste().preferences(FOOD_PREFERENCES)
     self.weather_opinion = WeatherOpinion().weather(self.GOOD_WEATHER)
     self.clo = ChiefLunchOfficer(food_taste=self.taste,
                                  weather_opinion=self.weather_opinion)
     self.clo.cafes(self.cafes)
 def setUp(self):
     self.food_taste = FoodTaste()
     self.food_taste.preferences({
         'item1': 1,
         'item2': 2,
         'item3': 3,
         'item4': 4,
         'item5': 5,
         'item6_part1 item6_part2': 6
     })
class FoodTasteTest(unittest.TestCase):

    def setUp(self):
        self.food_taste = FoodTaste()
        self.food_taste.preferences({
            'item1': 1,
            'item2': 2,
            'item3': 3,
            'item4': 4,
            'item5': 5,
            'item6_part1 item6_part2': 6
        })

    def test_unknown_food_one_item_menu(self):
        self.assertEqual(0, self.food_taste.rate('unknown_item'))

    def test_known_food_one_item_menu(self):
        self.assertEqual(3, self.food_taste.rate('item3'))

    def test_composite_menu_some_parts_unknown_highest_rating_is_chosen(self):
        self.assertEqual(4, self.food_taste.rate('item3 item4 then also something else'))

    def test_composite_menu_all_parts_unknown(self):
        self.assertEqual(4, self.food_taste.rate('item3 item4 item2'))

    def test_empty_menu_rating_is_zero(self):
        self.assertEqual(0, self.food_taste.rate(''))

    def test_repeating_item_on_menu_does_not_change_rating(self):
        self.assertEqual(1, self.food_taste.rate('item1 item1 item1 item1 item1'))

    def test_no_preferences_configured(self):
        self.food_taste = FoodTaste()
        self.assertEqual(0, self.food_taste.rate('item1'))

    def test_spaces_in_preferences(self):
        self.assertEqual(6, self.food_taste.rate('item6_part1 item6_part2 something else'))

    def test_case_in_menu_is_ignored(self):
        self.assertEqual(1, self.food_taste.rate('iTeM1'))
 def test_no_preferences_configured(self):
     self.food_taste = FoodTaste()
     self.assertEqual(0, self.food_taste.rate('item1'))
Example #6
0
    '\nWeather:\n\n temperature %s C\n chance of precipitation %s percent\n precipitation amount %s mm\n wind %s m/s'
    % (weather[TEMPERATURE], weather[PRECIPITATION_CHANCE],
       weather[PRECIPITATION_AMOUNT], weather[WIND]))

lunch_history = get_current_week_history(today)
current_week_cafes = ordered_cafes(lunch_history)
print('\nLunch history for current week:\n\n %s' %
      ', '.join(current_week_cafes))

cafes = deepcopy(CAFES)
cafes[SODEXO_EXPLORER]['menu'] = sodexo_explorer_menu
cafes[SODEXO_ACQUA]['menu'] = sodexo_acqua_menu
cafes[ANTELL]['menu'] = antell_menu
cafes[HIMA_SALI]['menu'] = hima_sali_menu
cafes[DYLAN_MILK]['menu'] = dylan_milk_menu
cafes[PIHKA]['menu'] = pihka_menu
cafes[FACTORY_SALMISAARI]['menu'] = factory_salmisaari_menu

food_taste = FoodTaste().preferences(FOOD_PREFERENCES)
weather_opinion = WeatherOpinion().weather(weather)
clo = ChiefLunchOfficer(food_taste=food_taste, weather_opinion=weather_opinion)
clo.lunched(current_week_cafes).weather(weather).cafes(cafes).weekday(
    today.weekday())
todays_cafes = clo.decide()
todays_cafe = todays_cafes[0]
todays_cafe_address = CAFES[todays_cafe]['address']
update_history(lunch_history, today, todays_cafe)
print('\nRecommendation:\n\n %s, %s' % (todays_cafe, todays_cafe_address))
formatted_cafes = ', '.join(todays_cafes[0:5]) + '\n' + ', '.join(
    todays_cafes[5:-1])
print('\nAll lunch in preferred order:\n\n %s' % (formatted_cafes))
Example #7
0
 def setUp(self):
     self.taste = FoodTaste().preferences({})
     self.weather = WeatherOpinion()
     self.weather.is_positive = Mock(return_value=True)
     self.clo = ChiefLunchOfficer(food_taste=self.taste,
                                  weather_opinion=self.weather)
Example #8
0
class FoodTasteTest(unittest.TestCase):
    def setUp(self):
        self.food_taste = FoodTaste()
        self.food_taste.preferences({
            'item1': 1,
            'item2': 2,
            'item3': 3,
            'item4': 4,
            'item5': 5,
            'item6_part1 item6_part2': 6
        })

    def test_unknown_food_one_item_menu(self):
        self.assertEqual(0, self.food_taste.rate('unknown_item'))

    def test_known_food_one_item_menu(self):
        self.assertEqual(3, self.food_taste.rate('item3'))

    def test_composite_menu_some_parts_unknown_highest_rating_is_chosen(self):
        self.assertEqual(
            4, self.food_taste.rate('item3 item4 then also something else'))

    def test_composite_menu_all_parts_unknown(self):
        self.assertEqual(4, self.food_taste.rate('item3 item4 item2'))

    def test_empty_menu_rating_is_zero(self):
        self.assertEqual(0, self.food_taste.rate(''))

    def test_repeating_item_on_menu_does_not_change_rating(self):
        self.assertEqual(1,
                         self.food_taste.rate('item1 item1 item1 item1 item1'))

    def test_no_preferences_configured(self):
        self.food_taste = FoodTaste()
        self.assertEqual(0, self.food_taste.rate('item1'))

    def test_spaces_in_preferences(self):
        self.assertEqual(
            6, self.food_taste.rate('item6_part1 item6_part2 something else'))

    def test_case_in_menu_is_ignored(self):
        self.assertEqual(1, self.food_taste.rate('iTeM1'))
Example #9
0
 def test_no_preferences_configured(self):
     self.food_taste = FoodTaste()
     self.assertEqual(0, self.food_taste.rate('item1'))