コード例 #1
0
    def test_tax_calculator(self):
        imported_perfume = Item(1,
                                'imported bottle of perfume',
                                27.99,
                                imported=True)
        basic_tax_perfume = self.tax_calculator.get_basic_sales_tax(
            imported_perfume)
        self.assertEqual(Decimal('2.8'), basic_tax_perfume)

        imported_tax_perfume = self.tax_calculator.get_import_duty_tax(
            imported_perfume)
        self.assertEqual(Decimal('1.4'), imported_tax_perfume)

        imported_tax_perfume = self.tax_calculator.get_total_tax(
            imported_perfume)
        self.assertEqual(Decimal('4.2'), imported_tax_perfume)

        headache_pills = MedicalProduct(1, 'packet of headache pills', 9.75)
        total_tax_pills = self.tax_calculator.get_total_tax(headache_pills)
        self.assertEqual(Decimal(0), total_tax_pills)

        chocolate_bar = Food(1,
                             'imported box of chocolates',
                             11.25,
                             imported=True)
        total_tax_choco = self.tax_calculator.get_total_tax(chocolate_bar)
        self.assertEqual(Decimal('0.6'), total_tax_choco)
コード例 #2
0
 def test_purchase(self):
     imported_perfume = Item(1,
                             'imported bottle of perfume',
                             27.99,
                             imported=True)
     perfume = Item(1, 'bottle of perfume', 18.99)
     headache_pills = MedicalProduct(1, 'packet of headache pills', 9.75)
     chocolate_bar = Food(1,
                          'imported box of chocolates',
                          11.25,
                          imported=True)
     self.user.purchase(imported_perfume)
     self.user.purchase(perfume)
     self.user.purchase(headache_pills)
     self.user.purchase(chocolate_bar)
     self.assertEqual(4, len(self.user.cart))
コード例 #3
0
    def test_tax_calculator(self):
        book = Book(1, 'book', 12.49)
        basic_tax_book = self.tax_calculator.get_basic_sales_tax(book)
        self.assertEqual(Decimal(0), basic_tax_book)

        music_cd = Item(1, 'music CD', 14.99)
        basic_tax_generic = self.tax_calculator.get_basic_sales_tax(music_cd)
        self.assertEqual(Decimal('1.5'), basic_tax_generic)
コード例 #4
0
 def test_purchase(self):
     book = Book(1, 'book', 12.49)
     music_cd = Item(1, 'music CD', 14.99)
     chocolate_bar = Food(1, 'chocolate bar', 0.85)
     self.user.purchase(book)
     self.user.purchase(music_cd)
     self.user.purchase(chocolate_bar)
     self.assertEqual(3, len(self.user.cart))
コード例 #5
0
 def test_print_receipt(self):
     choco = Food(1, 'imported box of chocolates', 10.00, imported=True)
     perfume = Item(1, 'imported bottle of perfume', 47.50, imported=True)
     self.user.purchase(choco)
     self.user.purchase(perfume)
     receipt = self.cash_register.print_receipt(self.user.cart)
     expected_receipt = [
         '1 imported box of chocolates: 10.50',
         '1 imported bottle of perfume: 54.65', 'Sales Taxes: 7.65',
         'Total: 65.15'
     ]
     self.assertEqual(expected_receipt, receipt)
コード例 #6
0
 def test_print_receipt(self):
     book = Book(1, 'book', 12.49)
     music_cd = Item(1, 'music CD', 14.99)
     chocolate_bar = Food(1, 'chocolate bar', 0.85)
     self.user.purchase(book)
     self.user.purchase(music_cd)
     self.user.purchase(chocolate_bar)
     receipt = self.cash_register.print_receipt(self.user.cart)
     expected_receipt = ['1 book: 12.49',
                         '1 music CD: 16.49',
                         '1 chocolate bar: 0.85',
                         'Sales Taxes: 1.50',
                         'Total: 29.83']
     self.assertEqual(expected_receipt, receipt)
コード例 #7
0
 def test_print_receipt(self):
     imported_perfume = Item(1,
                             'imported bottle of perfume',
                             27.99,
                             imported=True)
     perfume = Item(1, 'bottle of perfume', 18.99)
     headache_pills = MedicalProduct(1, 'packet of headache pills', 9.75)
     chocolate_bar = Food(1,
                          'imported box of chocolates',
                          11.25,
                          imported=True)
     self.user.purchase(imported_perfume)
     self.user.purchase(perfume)
     self.user.purchase(headache_pills)
     self.user.purchase(chocolate_bar)
     receipt = self.cash_register.print_receipt(self.user.cart)
     expected_receipt = [
         '1 imported bottle of perfume: 32.19',
         '1 bottle of perfume: 20.89', '1 packet of headache pills: 9.75',
         '1 imported box of chocolates: 11.85', 'Sales Taxes: 6.70',
         'Total: 74.68'
     ]
     self.assertEqual(expected_receipt, receipt)
コード例 #8
0
    def test_tax_calculator(self):
        choco = Food(1, 'imported box of chocolates', 10.00, imported=True)
        basic_tax_choco = self.tax_calculator.get_basic_sales_tax(choco)
        self.assertEqual(Decimal(0), basic_tax_choco)
        import_duty_tax_choco = self.tax_calculator.get_import_duty_tax(choco)
        self.assertEqual(Decimal('0.5'), import_duty_tax_choco)
        total_tax_choco = self.tax_calculator.get_total_tax(choco)
        self.assertEqual(Decimal('0.5'), total_tax_choco)

        perfume = Item(1, 'imported bottle of perfume', 47.50, imported=True)
        basic_tax_perfume = self.tax_calculator.get_basic_sales_tax(perfume)
        self.assertEqual(Decimal('4.75'), basic_tax_perfume)
        import_duty_tax_perfume = self.tax_calculator.get_import_duty_tax(
            perfume)
        self.assertEqual(Decimal('2.4'), import_duty_tax_perfume)
        total_tax_perfume = self.tax_calculator.get_total_tax(perfume)
        self.assertEqual(Decimal('7.15'), total_tax_perfume)
コード例 #9
0
 def test_purchase(self):
     choco = Food(1, 'imported box of chocolates', 10.00, imported=True)
     perfume = Item(1, 'imported bottle of perfume', 47.50, imported=True)
     self.user.purchase(choco)
     self.user.purchase(perfume)
     self.assertEqual(2, len(self.user.cart))