Exemplo n.º 1
0
 def test_invite_more_people(self):
     party = PizzaParty().invite(7).order(2)
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
     party.invite(9)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 2
0
 def test_invite_more_people(self):
     party = PizzaParty().invite(7).order(2)
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
     party.invite(9)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 3
0
 def test_order_more_pizza(self):
     party = PizzaParty().invite(8).order(2)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
     party.order(2)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(4, party.pieces_per_person())
Exemplo n.º 4
0
 def test_order_more_pizza(self):
     party = PizzaParty().invite(8).order(2)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
     party.order(2)
     self.assertEqual(0, party.leftovers())
     self.assertEqual(4, party.pieces_per_person())
Exemplo n.º 5
0
def run(read, prt):
    people = int(read('How many people? '))
    pizza_order = read('How many pizzas? ')
    order_parts = str.split(pizza_order)
    pizzas = int(order_parts[0])
    size = None
    if len(order_parts) == 2:
        size = order_parts[1]
    prt('%s people with %s pizzas' % (people, pizzas))
    party = PizzaParty().invite(people).order(pizzas, size)
    prt('Each person gets %s pieces of pizza.' % (party.pieces_per_person()))
    prt('There are %s leftover pieces.' % (party.leftovers()))
Exemplo n.º 6
0
def run(read, prt):
    people = int(read('How many people? '))
    pizza_order = read('How many pizzas? ')
    order_parts = str.split(pizza_order)
    pizzas = int(order_parts[0])
    size = None
    if len(order_parts) == 2:
        size = order_parts[1]
    prt('%s people with %s pizzas' % (people, pizzas))
    party = PizzaParty().invite(people).order(pizzas, size)
    prt('Each person gets %s pieces of pizza.' % (party.pieces_per_person()))
    prt('There are %s leftover pieces.' % (party.leftovers()))
Exemplo n.º 7
0
 def test_order_large_pizza(self):
     party = PizzaParty().invite(30).order(4, 'large')
     self.assertEqual(2, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 8
0
 def test_order_medium_pizza(self):
     party = PizzaParty().invite(5).order(2, 'medium')
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
Exemplo n.º 9
0
 def test_order_small_pizza(self):
     party = PizzaParty().invite(3).order(1, 'small')
     self.assertEqual(1, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 10
0
 def test_some_leftovers(self):
     party = PizzaParty().invite(7).order(2)
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
Exemplo n.º 11
0
 def test_no_leftovers(self):
     party = PizzaParty().invite(8).order(2)
     self.assertEqual(0, party.leftovers())
Exemplo n.º 12
0
 def test_order_large_pizza(self):
     party = PizzaParty().invite(30).order(4, 'large')
     self.assertEqual(2, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 13
0
 def test_order_medium_pizza(self):
     party = PizzaParty().invite(5).order(2, 'medium')
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
Exemplo n.º 14
0
 def test_order_small_pizza(self):
     party = PizzaParty().invite(3).order(1, 'small')
     self.assertEqual(1, party.leftovers())
     self.assertEqual(1, party.pieces_per_person())
Exemplo n.º 15
0
 def test_some_leftovers(self):
     party = PizzaParty().invite(7).order(2)
     self.assertEqual(2, party.leftovers())
     self.assertEqual(2, party.pieces_per_person())
Exemplo n.º 16
0
 def test_no_leftovers(self):
     party = PizzaParty().invite(8).order(2)
     self.assertEqual(0, party.leftovers())