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.

test_shipping_methods.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from decimal import Decimal as D
  2. from django.test import TestCase
  3. import mock
  4. from apps.shipping import methods
  5. class TestStandard(TestCase):
  6. def setUp(self):
  7. self.method = methods.Standard()
  8. self.basket = mock.Mock()
  9. def test_is_free_over_threshold(self):
  10. self.basket.total_incl_tax = D('20.00')
  11. price = self.method.calculate(self.basket)
  12. self.assertEqual(price.incl_tax, D('0.00'))
  13. def test_is_per_item_under_threshold(self):
  14. self.basket.total_incl_tax = D('10.00')
  15. self.basket.num_items = 3
  16. price = self.method.calculate(self.basket)
  17. self.assertEqual(
  18. price.incl_tax, 3 * self.method.charge_per_item)
  19. class TestExpress(TestCase):
  20. def setUp(self):
  21. self.method = methods.Express()
  22. self.basket = mock.Mock()
  23. def test_is_per_item_under_threshold(self):
  24. self.basket.total_incl_tax = D('10.00')
  25. self.basket.num_items = 3
  26. price = self.method.calculate(self.basket)
  27. self.assertEqual(
  28. price.incl_tax, 3 * self.method.charge_per_item)