You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tax_mixin_tests.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from decimal import Decimal as D
  2. from django.test import TestCase
  3. import mock
  4. from oscar.apps.partner import strategy
  5. class TestNoTaxMixin(TestCase):
  6. def setUp(self):
  7. self.mixin = strategy.NoTax()
  8. self.product = mock.Mock()
  9. self.stockrecord = mock.Mock()
  10. self.stockrecord.price_excl_tax = D('12.00')
  11. def test_returns_no_prices_without_stockrecord(self):
  12. policy = self.mixin.pricing_policy(
  13. self.product, None)
  14. self.assertFalse(policy.exists)
  15. def test_returns_zero_tax(self):
  16. policy = self.mixin.pricing_policy(
  17. self.product, self.stockrecord)
  18. self.assertEquals(D('0.00'), policy.tax)
  19. def test_doesnt_add_tax_to_net_price(self):
  20. policy = self.mixin.pricing_policy(
  21. self.product, self.stockrecord)
  22. self.assertEquals(D('12.00'), policy.incl_tax)
  23. class TestFixedRateTaxMixin(TestCase):
  24. def setUp(self):
  25. self.mixin = strategy.FixedRateTax()
  26. self.mixin.rate = D('0.10')
  27. self.product = mock.Mock()
  28. self.stockrecord = mock.Mock()
  29. self.stockrecord.price_excl_tax = D('12.00')
  30. def test_returns_no_prices_without_stockrecord(self):
  31. policy = self.mixin.pricing_policy(
  32. self.product, None)
  33. self.assertFalse(policy.exists)
  34. def test_returns_correct_tax(self):
  35. policy = self.mixin.pricing_policy(
  36. self.product, self.stockrecord)
  37. self.assertEquals(self.mixin.rate * self.stockrecord.price_excl_tax,
  38. policy.tax)
  39. def test_adds_tax_to_net_price(self):
  40. policy = self.mixin.pricing_policy(
  41. self.product, self.stockrecord)
  42. self.assertEquals(D('13.20'), policy.incl_tax)