class TaxationPolicyTestCase(TestCase): def setUp(self): self.taxation_policy = TaxationPolicy() def test_taxation_policy_returns_plans_tax_or_none(self): """ PLANS_TAX should be returned if it exists, otherwise None should be returned """ tax_value = Decimal(15.0) with self.settings(PLANS_TAX=tax_value): self.assertEquals(tax_value, self.taxation_policy.get_default_tax()) with self.settings(PLANS_TAX=None): self.assertEquals(None, self.taxation_policy.get_default_tax()) def test_taxation_policy_raise_error_default_is_not_decimal(self): """ If PLANS_TAX is not a decimal or None, then a ValueError should be raised by the application. """ with self.settings(PLANS_TAX=''): self.assertRaises(TypeError, self.taxation_policy.get_default_tax) def test_get_tax_rate_raises_not_implemented(self): """ This method should be overriden by children. Should raise NotImplementedError exception by default """ with self.assertRaises(NotImplementedError): self.taxation_policy.get_tax_rate('tax_id', 'country_code')