def test_compute(self): myItems = item() myItem = item.classify(myItems, inputs['smtext']) myItem.num_items = 5 myItems.price = 1.00 myCompute = item.compute(myItems) self.assertEqual(myItem.taxes, float(inputs['taxes']))
def test_create_total(self): receipt = [] myItems = item() myItem = item.classify(myItems, inputs['smtext']) receipt.append(create_line(myItems, inputs['smtext'])) test = create_total(receipt) self.assertEqual(test, inputs['smtext_out'])
def myReceipt(f): try: myItems = item() lines = f.read().splitlines() receipt = [] try: for line in lines: # get our updated items with taxes and totals myItem = myItems.classify(line) myItems.compute() myItems.roundup() myItems.sub_total() receipt.append(create_line(myItems, line)) # create the final receipt return create_total(receipt) except Exception as e: print e except Exception as e: print e
def test_create_line(self): myItems = item() myItem = item.classify(myItems, inputs['smtext']) test = (create_line(myItems, inputs['smtext'])) self.assertEqual(test[0], inputs['cl_tax'])
def test_subtotal(self): myItems = item() myItem = item.classify(myItems, inputs['smtext']) myItems.sub_total() self.assertEqual(myItem.subtotal, float(inputs['subtotal']))
def test_roundup(self): myItems = item() myItem = item.classify(myItems, inputs['smtext']) myItem.taxes = inputs['rtaxes'] myItems.roundup() self.assertEqual(myItem.taxes, float(inputs['roundup_ans']))
def test_classify(self): myItems = item() myItem = item.classify(myItems, inputs['smtext']) self.assertEqual(str(myItem.tax), inputs['tax']) self.assertEqual(str(myItem.duty), inputs['duty']) self.assertEqual(myItem.price, float(inputs['price']))
def test_classify_items_init(self): myItems = item() with open('classifications.json', 'r') as f: read_data = f.read() jsonData = json.loads(read_data) self.assertEqual(myItems.item_class, jsonData)