"""Tests for invoice_total.py. Run:  python3 -m unittest test_invoice_total.py
Do not change this file: the task is to fix invoice_total.py until every test passes."""
import unittest

from invoice_total import invoice_total


class InvoiceTotalTest(unittest.TestCase):
    def test_no_discount(self):
        # 2 x $10.00 = $20.00, tax 8.25% = $1.65
        self.assertEqual(invoice_total([(2, 1000)], 0.0825), 2165)

    def test_discount_starts_at_ten_items(self):
        # 10 x $1.00 = $10.00, minus 5% = $9.50, tax 10% = $10.45
        self.assertEqual(invoice_total([(10, 100)], 0.10), 1045)

    def test_discount_before_tax(self):
        # 20 x $5.00 = $100.00, minus 5% = $95.00, tax 8.25% = $102.8375 -> $102.84
        self.assertEqual(invoice_total([(20, 500)], 0.0825), 10284)

    def test_ten_percent_at_fifty(self):
        # 50 x $2.00 = $100.00, minus 10% = $90.00, no tax
        self.assertEqual(invoice_total([(50, 200)], 0.0), 9000)

    def test_rounds_half_up(self):
        # 1 x $0.10, tax 5% = 10.5 cents -> 11 cents
        self.assertEqual(invoice_total([(1, 10)], 0.05), 11)

    def test_empty_invoice(self):
        self.assertEqual(invoice_total([], 0.0825), 0)


if __name__ == "__main__":
    unittest.main()
