Exemplo n.º 1
0
Arquivo: shop.py Projeto: aj178/Bakery
#!/usr/bin/env python

from lib.Bakery import *
import sys

if __name__ == '__main__':

    bakery = Bakery()
    if len(sys.argv) == 2:
        input_file = sys.argv[1]
        with open(input_file, 'r') as order_file:
            text = order_file.read()
        bakery = Bakery()
        bakery.place_order(text)
    else:
        lines = []
        print("Place order:")
        while True:
            line = raw_input()
            if line:
                lines.append(line)
            else:
                break
        text = '\n'.join(lines)
        bakery.place_order(text)
Exemplo n.º 2
0
 def test_redundant_code_input(self):
     bakery = Bakery()
     redundant_code_input = bakery.place_order("10 VS5\n13 CF\n 10 VS5")
     self.assertEqual(redundant_code_input, ['17.98', '25.85', '17.98'])
Exemplo n.º 3
0
 def test_empty_input(self):
     bakery = Bakery()
     empty_order = bakery.place_order("")
     self.assertEqual(empty_order, "order empty")
Exemplo n.º 4
0
 def test_three_code_input(self):
     bakery = Bakery()
     three_code_input = bakery.place_order("10 VS5\n14 MB11\n13 CF")
     self.assertEqual(three_code_input, ['17.98', '47.80', '25.85'])
Exemplo n.º 5
0
 def test_two_code_input(self):
     bakery = Bakery()
     two_code_input = bakery.place_order("10 VS5\n14 MB11")
     self.assertEqual(two_code_input, ['17.98', '47.80'])
Exemplo n.º 6
0
 def test_one_code_input(self):
     bakery = Bakery()
     one_code_input = bakery.place_order("10 VS5")
     self.assertEqual(one_code_input, ['17.98'])
Exemplo n.º 7
0
 def test_invalid_quantity(self):
     bakery = Bakery()
     invalid_quantity = bakery.place_order("10.5 VS5")
     self.assertEqual(invalid_quantity, "Invalid quantity")
Exemplo n.º 8
0
 def test_invalid_code(self):
     bakery = Bakery()
     invalid_code = bakery.place_order("10 Vs5")
     self.assertEqual(invalid_code, "Invalid code")