def test_init_basic(self): """ Test Tax.__init__ with only mandatory arguments. """ tax = Tax(self.tax_brackets, inflation_adjust=self.inflation_adjustments) for year in self.tax_brackets: self.assertEqual(tax.tax_brackets(year), self.tax_brackets[year]) self.assertEqual(tax.accum(year), self.accum[year]) self.assertTrue(callable(tax.inflation_adjust)) self.assertEqual(tax.personal_deduction(self.initial_year), 0) self.assertEqual(tax.credit_rate(self.initial_year), 1)
def test_init_type_conv_str(self): """ Tests Tax.__init__ with args requiring type-conversion. """ # Use an all-str dict and confirm that the output is correctly # typed tax_brackets = { str(year): { str(bracket.amount): str(self.tax_brackets[year][bracket]) for bracket in self.tax_brackets[year] } for year in self.tax_brackets } inflation_adjustments = { str(year): str(self.inflation_adjustments[year]) for year in self.inflation_adjustments } tax = Tax(tax_brackets, inflation_adjust=inflation_adjustments) for year in self.tax_brackets: self.assertEqual(tax.tax_brackets(year), self.tax_brackets[year]) self.assertTrue( type_check(tax.tax_brackets(year), {Money: Decimal})) self.assertTrue(callable(tax.inflation_adjust))
def test_init_optional(self): """ Test Tax.__init__ with all arguments, including optional. """ tax = Tax(self.tax_brackets, inflation_adjust=self.inflation_adjustments, personal_deduction=self.personal_deduction, credit_rate=self.credit_rate) for year in self.tax_brackets: self.assertEqual(tax.tax_brackets(year), self.tax_brackets[year]) self.assertEqual(tax.accum(year), self.accum[year]) self.assertEqual(tax.personal_deduction(year), self.personal_deduction[year]) self.assertEqual(tax.credit_rate(year), self.credit_rate[year]) self.assertTrue(callable(tax.inflation_adjust))