Esempio n. 1
0
    def test_dog_decimal(self):
        with self.assertRaises(Exception) as context:
            order_dog_food(5, 3, 7.88, 17)

        self.assertEqual(
            'Please enter whole numbers for each dog size category',
            str(context.exception))
Esempio n. 2
0
    def test_leftover_string(self):
        with self.assertRaises(Exception) as context:
            order_dog_food(1, 2, 7, "seven")

        self.assertEqual(
            'Please enter a number for the amount of food in lbs leftover from the previous month.',
            str(context.exception))
Esempio n. 3
0
    def test_more_dogs_than_max(self):
        with self.assertRaises(Exception) as context:
            order_dog_food(30, 30, 1, 17)

        self.assertEqual(
            'You\'ve entered 61 which is more dogs than the shelter\'s max capacity of 30. Please check your numbers and try again.',
            str(context.exception))
Esempio n. 4
0
    def test_dog_string(self):
        with self.assertRaises(Exception) as context:
            order_dog_food(1, "Fuffy", 7, 17)

        self.assertEqual(
            'Please enter whole numbers for each dog size category',
            str(context.exception))
Esempio n. 5
0
 def test_max_dogs(self):
     self.assertEqual(
         order_dog_food(10, 10, 10, 25),
         695,
         msg=
         "You should be able to have exactly the max capacity of dogs in the shelter"
     )
Esempio n. 6
0
 def test_no_leftovers(self):
     self.assertEqual(
         order_dog_food(7, 1, 1, 0),
         144,
         msg=
         "You should be able to have 0lbs of leftover food from the previous month"
     )
Esempio n. 7
0
 def test_leftover_greater_than_order(self):
     self.assertEqual(
         order_dog_food(1, 1, 0, 50),
         0,
         msg=
         "If you have more leftover food than the total order amount, you should order 0 lbs of food this month"
     )
Esempio n. 8
0
    def test_negative_dogs(self):
        with self.assertRaises(Exception) as context:
            order_dog_food(-5, 3, 7, 17)

        self.assertEqual('Please enter 0 or more dogs for each size category',
                         str(context.exception))
Esempio n. 9
0
 def test_happiest_path(self):
     self.assertEqual(order_dog_food(5, 3, 7, 17),
                      367,
                      msg="The total order calculation is incorrect")
Esempio n. 10
0
 def test_large_dog_amount(self):
     self.assertEqual(
         order_dog_food(0, 0, 1, 0),
         36,
         msg="If you have only 1 large dog you should order 36 lbs of food")
Esempio n. 11
0
 def test_medium_dog_amount(self):
     self.assertEqual(
         order_dog_food(0, 1, 0, 0),
         24,
         msg="If you have only 1 medium dog you should order 24 lbs of food"
     )
Esempio n. 12
0
 def test_small_dog_amount(self):
     self.assertEqual(
         order_dog_food(1, 0, 0, 0),
         12,
         msg="If you have only 1 small dog you should order 12 lbs of food")
Esempio n. 13
0
 def test_zero_dogs(self):
     self.assertEqual(
         order_dog_food(1, 0, 0, 17.5),
         0,
         msg="You should be able to have zero dogs in a size category")
Esempio n. 14
0
 def test_leftover_food_decimal(self):
     self.assertEqual(order_dog_food(5, 3, 7, 17.5),
                      366.5,
                      msg="The leftover food value should accept a decimal")
Esempio n. 15
0
#!/usr/bin/python

import argparse
import food_order

parser = argparse.ArgumentParser()
parser.add_argument("small_dogs",
                    type=int,
                    help="The number of small dogs in the shelter")
parser.add_argument("medium_dogs",
                    type=int,
                    help="The number of medium dogs in the shelter")
parser.add_argument("large_dogs",
                    type=int,
                    help="The number of large dogs in the shelter")
parser.add_argument(
    "leftover_food",
    type=float,
    help="The amount of food leftover from the previous month in lbs")
args = parser.parse_args()

total_order = food_order.order_dog_food(args.small_dogs, args.medium_dogs,
                                        args.large_dogs, args.leftover_food)
print(f"Please order {total_order} lbs of food for this month.")