def testCantChangeSetting(self): """When overridden, setting a value should not work, should get the overridden value""" c = config_get('overgroup', 's2') c.update(1) c = config_get('overgroup', 's2') self.assertEquals(c.value, 100)
def testCantChangeSetting(self): """When overridden, setting a value should not work, should get the overridden value""" c = config_get('overgroup', 's2') c.update(1) c = config_get('overgroup', 's2') self.assertEqual(c.value, 100)
def test_checkout(self): """ Run through a full checkout process """ cache_delete() tax = config_get('TAX','MODULE') tax.update('tax.modules.percent') pcnt = config_get('TAX', 'PERCENT') pcnt.update('10') shp = config_get('TAX', 'TAX_SHIPPING_PERCENT') shp.update(False) self.test_cart_adding() response = self.client.post(url('satchmo_checkout-step1'), get_step1_post_data(self.US)) self.assertRedirects(response, url('DUMMY_satchmo_checkout-step2'), status_code=302, target_status_code=200) data = { 'credit_type': 'Visa', 'credit_number': '4485079141095836', 'month_expires': '1', 'year_expires': '2015', 'ccv': '552', 'shipping': 'FlatRate'} response = self.client.post(url('DUMMY_satchmo_checkout-step2'), data) self.assertRedirects(response, url('DUMMY_satchmo_checkout-step3'), status_code=302, target_status_code=200) response = self.client.get(url('DUMMY_satchmo_checkout-step3')) amount = smart_str('Shipping + ' + moneyfmt(Decimal('4.00'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Tax + ' + moneyfmt(Decimal('4.60'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Total = ' + moneyfmt(Decimal('54.60'))) self.assertContains(response, amount, count=1, status_code=200) response = self.client.post(url('DUMMY_satchmo_checkout-step3'), {'process' : 'True'}) self.assertRedirects(response, url('DUMMY_satchmo_checkout-success'), status_code=302, target_status_code=200) self.assertEqual(len(mail.outbox), 1) # Log in as a superuser user = User.objects.create_user('fredsu', '*****@*****.**', 'passwd') user.is_staff = True user.is_superuser = True user.save() self.client.login(username='******', password='******') # Test invoice, packing slip and shipping label generation order_id = Order.objects.all()[0].id response = self.client.get('/admin/print/invoice/%d/' % order_id) self.assertEqual(response.status_code, 200) response = self.client.get('/admin/print/packingslip/%d/' % order_id) self.assertEqual(response.status_code, 200) response = self.client.get('/admin/print/shippinglabel/%d/' % order_id) self.assertEqual(response.status_code, 200)
def _set_percent_taxer(percent): cache_delete() tax = config_get('TAX','MODULE') tax.update('tax.modules.percent') pcnt = config_get('TAX', 'PERCENT') pcnt.update(percent) shp = config_get('TAX', 'TAX_SHIPPING_PERCENT') shp.update(False) return shp
def _set_percent_taxer(percent): cache_delete() tax = config_get('TAX', 'MODULE') tax.update('tax.modules.percent') pcnt = config_get('TAX', 'PERCENT') pcnt.update(percent) shp = config_get('TAX', 'TAX_SHIPPING_PERCENT') shp.update(False) return shp
def testDefault(self): c = config_get('mv2', 'c1') self.assertEqual(c.value, [1, 2]) c.update([1, 2, 3]) self.assertEqual(c.value, [1, 2, 3])
def testDuplicateAdminAreas(self): """Test the situation where we have multiple adminareas with the same name""" cache_delete() tax = config_get('TAX','MODULE') tax.update('tax.modules.area') order = make_test_order('GB', 'Manchester') order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('100.00')) self.assertEqual(tax, Decimal('20.00')) # 100 + 10 shipping + 20 tax self.assertEqual(price, Decimal('130.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('20.00')) self.assertEqual(tship.tax, Decimal('0.00'))
def testDuplicateAdminAreas(self): """Test the situation where we have multiple adminareas with the same name""" cache_delete() tax = config_get('TAX', 'MODULE') tax.update('tax.modules.area') order = make_test_order('GB', 'Manchester') order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('100.00')) self.assertEqual(tax, Decimal('20.00')) # 100 + 10 shipping + 20 tax self.assertEqual(price, Decimal('130.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('20.00')) self.assertEqual(tship.tax, Decimal('0.00'))
def testTwice(self): """Config items should respond False to duplicate requests to update.""" c = config_get('test2', 's1') c.update('test1') self.assertFalse(c.update('test1'))
def testRequiresValue(self): c = config_get('BASE', 'groupchoice') self.assertEquals(c.value, []) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, []) c2 = config_get('BASE', 'groupchoice2') c2.update('bar') keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['c2']) c.update(['groupreq']) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['c1', 'c2', 'c3'])
def testRequiresValue(self): c = config_get('BASE', 'groupchoice') self.assertEqual(c.value, []) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, []) c2 = config_get('BASE', 'groupchoice2') c2.update('bar') keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['c2']) c.update(['groupreq']) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['c1', 'c2', 'c3'])
def testAreaCountries(self): """Test Area tax module""" cache_delete() tax = config_get('TAX', 'MODULE') tax.update('tax.modules.area') order = make_test_order('DE', '', include_non_taxed=True) order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('105.00')) self.assertEqual(tax, Decimal('20.00')) # 100 + 10 shipping + 20 tax self.assertEqual(price, Decimal('135.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('20.00')) self.assertEqual(tship.tax, Decimal('0.00')) order = make_test_order('CH', '') order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('100.00')) self.assertEqual(tax, Decimal('16.00')) # 100 + 10 shipping + 16 tax self.assertEqual(price, Decimal('126.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('16.00')) self.assertEqual(tship.tax, Decimal('0.00'))
def testAreaCountries(self): """Test Area tax module""" cache_delete() tax = config_get('TAX','MODULE') tax.update('tax.modules.area') order = make_test_order('DE', '', include_non_taxed=True) order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('105.00')) self.assertEqual(tax, Decimal('20.00')) # 100 + 10 shipping + 20 tax self.assertEqual(price, Decimal('135.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('20.00')) self.assertEqual(tship.tax, Decimal('0.00')) order = make_test_order('CH', '') order.recalculate_total(save=False) price = order.total subtotal = order.sub_total tax = order.tax self.assertEqual(subtotal, Decimal('100.00')) self.assertEqual(tax, Decimal('16.00')) # 100 + 10 shipping + 16 tax self.assertEqual(price, Decimal('126.00')) taxes = order.taxes.all() self.assertEqual(2, len(taxes)) t1 = taxes[0] t2 = taxes[1] self.assert_('Shipping' in (t1.description, t2.description)) if t1.description == 'Shipping': tship = t1 tmain = t2 else: tship = t2 tmain = t1 self.assertEqual(tmain.tax, Decimal('16.00')) self.assertEqual(tship.tax, Decimal('0.00'))
def testOverriddenListSetting(self): """Make sure lists work when overridden""" c = config_get('overgroup', 'choices') v = c.value self.assertEqual(len(v), 3) self.assertEqual(v[0], "one") self.assertEqual(v[1], "two") self.assertEqual(v[2], "three")
def testSetAndReset(self): """Test setting one value and then updating""" c = config_get('test2', 's1') c.update('test1') self.assertEqual(c.value, 'test1') # should be true, since it is an update self.assert_(c.update('test2')) self.assertEqual(c.value, 'test2')
def testSetAndReset(self): """Test setting one value and then updating""" c = config_get('test2', 's1') c.update('test1') self.assertEqual(c.value, 'test1') # should be true, since it is an update self.assertTrue(c.update('test2')) self.assertEqual(c.value, 'test2')
def test_cart_adding_errors_out_of_stock(self): # If no_stock_checkout is False, you should not be able to order a # product that is out of stock. setting = config_get('PRODUCT','NO_STOCK_CHECKOUT') setting.update(False) response = self.client.post(prefix + '/cart/add/', {'productname': 'neat-book', '3': 'soft', 'quantity': '1'}, follow=True) url = prefix + '/product/neat-book-soft/' self.assertRedirects(response, url, status_code=302, target_status_code=200) self.assertContains(response, "A really neat book (Soft cover)' is out of stock.", count=1)
def testRequiresSingleValue(self): v = config_value('BASE', 'valchoices2') self.assertEquals(v, 'a') keys = [cfg.key for cfg in self.g2] self.assertEqual(keys, ['c1']) c = config_get('BASE', 'valchoices2') c.update('b') keys = [cfg.key for cfg in self.g2] self.assertEqual(keys, ['c2'])
def testAddPreregisteredChoice(self): """Test that we can register choices before the config is actually set up.""" config_add_choice('ctg1', 'c1', ('a', 'Item A')) config_add_choice('ctg1', 'c1', ('b', 'Item B')) config_add_choice('ctg1', 'c1', ('c', 'Item C')) g1 = ConfigurationGroup('ctg1', 'Choice 1', ordering=1000) config_register(StringValue(g1, 'c1')) c = config_get('ctg1', 'c1') self.assertEqual(c.choices, [('a', 'Item A'), ('b', 'Item B'), ('c', 'Item C')])
def testRequiresSingleValue(self): v = config_value('BASE', 'valchoices2') self.assertEqual(v, 'a') keys = [cfg.key for cfg in self.g2] self.assertEqual(keys, ['c1']) c = config_get('BASE', 'valchoices2') c.update('b') keys = [cfg.key for cfg in self.g2] self.assertEqual(keys, ['c2'])
def testSimpleRequires(self): v = config_value('req1', 'bool2') self.assertTrue(v) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['bool1', 'bool2', 'c2', 'c3']) c = config_get('req1', 'bool1') c.update(True) keys = [cfg.key for cfg in self.g1] self.assertEqual(keys, ['bool1', 'bool2', 'c1', 'c2', 'c3'])
def setUp(self): self.US = Country.objects.get(iso2_code__iexact='US') self.site = Site.objects.get_current() tax = config_get('TAX', 'MODULE') tax.update('tax.modules.no') c = Contact(first_name="Jim", last_name="Tester", role=ContactRole.objects.get(pk='Customer'), email="*****@*****.**") c.save() ad = AddressBook(contact=c, description="home", street1="test", state="OR", city="Portland", country=self.US, is_default_shipping=True, is_default_billing=True) ad.save() o = Order(contact=c, shipping_cost=Decimal('6.00'), site=self.site) o.save() small = Order(contact=c, shipping_cost=Decimal('6.00'), site=self.site) small.save() p = Product.objects.get(slug='neat-book-soft') price = p.unit_price item1 = OrderItem(order=o, product=p, quantity='1', unit_price=price, line_item_price=price) item1.save() item1s = OrderItem(order=small, product=p, quantity='1', unit_price=price, line_item_price=price) item1s.save() p = Product.objects.get(slug='neat-book-hard') price = p.unit_price item2 = OrderItem(order=o, product=p, quantity='1', unit_price=price, line_item_price=price) item2.save() self.order = o self.small = small rebuild_pricing()
def testSimpleRequiresChoices(self): v = config_value('BASE', 'rc1') self.assertEqual(v, ['c1']) g = config_get_group('req2') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c3']) c = config_get('BASE', 'rc1') c.update(['c1', 'c2']) g = config_get_group('req2') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c2', 'c3'])
def test_cart_removing(self): """ Validate we can remove an item """ setting = config_get('PRODUCT','NO_STOCK_CHECKOUT') setting.update(True) self.test_cart_adding(retest=True) response = self.client.get(prefix+'/cart/') cartitem_id = response.context[0]['cart'].cartitem_set.all()[0].id response = self.client.post(prefix + '/cart/remove/', {'cartitem': str(cartitem_id)}) #self.assertRedirects(response, prefix + '/cart/', # status_code=302, target_status_code=200) response = self.client.get(prefix+'/cart/') self.assertContains(response, "Your cart is empty.", count=1, status_code=200)
def testRequiresValue(self): v = config_value('BASE', 'valchoices') self.assertEqual(v, ['foo']) g = config_get_group('reqval') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c3']) c = config_get('BASE', 'valchoices') c.update(['foo', 'bar']) g = config_get_group('reqval') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c2', 'c3'])
def testRequiresValue(self): v = config_value('BASE', 'valchoices') self.assertEquals(v, ['foo']) g = config_get_group('reqval') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c3']) c = config_get('BASE', 'valchoices') c.update(['foo', 'bar']) g = config_get_group('reqval') keys = [cfg.key for cfg in g] self.assertEqual(keys, ['c1', 'c2', 'c3'])
def test_cart_removing(self): """ Validate we can remove an item """ setting = config_get('PRODUCT', 'NO_STOCK_CHECKOUT') setting.update(True) self.test_cart_adding(retest=True) response = self.client.get(prefix + '/cart/') cartitem_id = response.context[0]['cart'].cartitem_set.all()[0].id response = self.client.post(prefix + '/cart/remove/', {'cartitem': str(cartitem_id)}) #self.assertRedirects(response, prefix + '/cart/', # status_code=302, target_status_code=200) response = self.client.get(prefix + '/cart/') self.assertContains(response, "Your cart is empty.", count=1, status_code=200)
def update(self, key, value, language_code=None): try: setting = config_get(self.__group_map[key], key) if setting.localized: lang = language_code or get_language() else: lang = None setting.update(value, lang) except: from livesettings.models import Setting lang_postfix = '_' + get_language().upper() # first try localized setting try: setting = Setting.objects.get(key=key + lang_postfix) except Setting.DoesNotExist: setting = Setting.objects.get(key=key) setting.value = value setting.save()
def testDeletesDefault(self): c = config_get('test2', 's3') # false because it isn't saving a default value self.assertFalse(c.update(10)) self.assert_(c.update(20)) self.assertEqual(c.value, 20) try: s = c.setting except SettingNotSet: self.fail("Should have a setting now") # now delete and go back to no setting by setting the default self.assert_(c.update(10)) self.assertEqual(c.value, 10) try: s = c.setting self.fail('Should throw SettingNotSet') except SettingNotSet: pass
def test_cart_adding_errors_out_of_stock(self): # If no_stock_checkout is False, you should not be able to order a # product that is out of stock. setting = config_get('PRODUCT', 'NO_STOCK_CHECKOUT') setting.update(False) response = self.client.post(prefix + '/cart/add/', { 'productname': 'neat-book', '3': 'soft', 'quantity': '1' }, follow=True) url = prefix + '/product/neat-book-soft/' self.assertRedirects(response, url, status_code=302, target_status_code=200) self.assertContains( response, "A really neat book (Soft cover)' is out of stock.", count=1)
def testDeletesDefault(self): c = config_get('test2', 's3') # false because it isn't saving a default value self.assertFalse(c.update(10)) self.assertTrue(c.update(20)) self.assertEqual(c.value, 20) try: s = c.setting except SettingNotSet: self.fail("Should have a setting now") # now delete and go back to no setting by setting the default self.assertTrue(c.update(10)) self.assertEqual(c.value, 10) try: s = c.setting self.fail('Should throw SettingNotSet') except SettingNotSet: pass
def test_checkout_minimums(self): """ Validate we can add some items to the cart """ min_order = config_get('PAYMENT', 'MINIMUM_ORDER') #start with no min. min_order.update("0.00") producturl = urlresolvers.reverse("satchmo_product", kwargs={'product_slug' : 'dj-rocks'}) response = self.client.get(producturl) self.assertContains(response, "Django Rocks shirt", count=2, status_code=200) cartadd = urlresolvers.reverse('satchmo_cart_add') response = self.client.post(cartadd, { "productname" : "dj-rocks", "1" : "L", "2" : "BL", "quantity" : '2'}) carturl = urlresolvers.reverse('satchmo_cart') self.assertRedirects(response, carturl, status_code=302, target_status_code=200) response = self.client.get(carturl) self.assertContains(response, "Django Rocks shirt (Large/Blue)", count=1, status_code=200) response = self.client.get(url('satchmo_checkout-step1')) self.assertContains(response, "Billing Information", count=1, status_code=200) # now check for min order not met min_order.update("100.00") response = self.client.get(url('satchmo_checkout-step1')) self.assertContains(response, "This store requires a minimum order", count=1, status_code=200) # add a bunch of shirts, to make the min order response = self.client.post(cartadd, { "productname" : "dj-rocks", "1" : "L", "2" : "BL", "quantity" : '10'}) self.assertRedirects(response, carturl, status_code=302, target_status_code=200) response = self.client.get(url('satchmo_checkout-step1')) self.assertContains(response, "Billing Information", count=1, status_code=200)
def setUp(self): self.US = Country.objects.get(iso2_code__iexact = 'US') self.site = Site.objects.get_current() tax = config_get('TAX','MODULE') tax.update('tax.modules.no') c = Contact(first_name="Jim", last_name="Tester", role=ContactRole.objects.get(pk='Customer'), email="*****@*****.**") c.save() ad = AddressBook(contact=c, description="home", street1 = "test", state="OR", city="Portland", country = self.US, is_default_shipping=True, is_default_billing=True) ad.save() o = Order(contact=c, shipping_cost=Decimal('6.00'), site=self.site) o.save() small = Order(contact=c, shipping_cost=Decimal('6.00'), site=self.site) small.save() p = Product.objects.get(slug='neat-book-soft') price = p.unit_price item1 = OrderItem(order=o, product=p, quantity='1', unit_price=price, line_item_price=price) item1.save() item1s = OrderItem(order=small, product=p, quantity='1', unit_price=price, line_item_price=price) item1s.save() p = Product.objects.get(slug='neat-book-hard') price = p.unit_price item2 = OrderItem(order=o, product=p, quantity='1', unit_price=price, line_item_price=price) item2.save() self.order = o self.small = small rebuild_pricing()
def testSave(self): c = config_get('m1', 'c1') c.update([1, 2]) self.assertEqual(c.value, [1, 2])
def testNotOverriddenSetting(self): """Settings which are not overridden should return their defaults""" c = config_get('overgroup', 's3') self.assertEquals(c.value, 10)
def testSettingDefault(self): c = config_get('test2', 's2') self.assertEqual(c.value, 10)
def testOverriddenSetting(self): """Accessing an overridden setting should give the override value.""" c = config_get('overgroup', 's2') self.assertEquals(c.value, 100)
def testAddChoice(self): config_add_choice('m1', 'c1', (4, 'four')) c = config_get('m1', 'c1') self.assertEqual(c.choices, ((1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')))
def testSetSetting(self): c = config_get('test2', 's1') c.update('test') self.assertEqual(c.value, 'test') self.assertEqual(c.setting.value, 'test')
def setUp(self): cfg = config_get('NEWSLETTER', 'MODULE') cfg.update('satchmo_ext.newsletter.simple') self.client = Client()
''' Canada Post Shipping Module v0.1.1 ''' from django.utils.translation import ugettext_lazy as _ from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, MultipleStringValue from livesettings.functions import config_register_list, config_get SHIP_MODULES = config_get('SHIPPING', 'MODULES') SHIP_MODULES.add_choice(('shipping.modules.canadapost', 'Canada Post')) SHIPPING_GROUP = ConfigurationGroup( 'shipping.modules.canadapost', _('Canada Post Shipping Settings'), requires=SHIP_MODULES, requiresvalue='shipping.modules.canadapost', ordering=101) config_register_list( StringValue(SHIPPING_GROUP, 'CPCID', description=_('Canada Post Merchant ID'), help_text=_('The merchant ID assigned by Canada Post'), default='CPC_DEMO_XML'), #http://sellonline.canadapost.ca/DevelopersResources/protocolV3/ProductID.html MultipleStringValue( SHIPPING_GROUP, 'CANADAPOST_SHIPPING_CHOICES', description=_("Canada Post shipping choices available to customers."), choices=(
def testNotOverriddenSetting(self): """Settings which are not overridden should return their defaults""" c = config_get('overgroup', 's3') self.assertEqual(c.value, 10)
def testModule(self): c = config_get('modules', 'test') c.update('django') self.assert_(hasattr(self.c.value, 'get_version'))
def testSettingProperty(self): c = config_get('test3', 's2') s = c.setting self.assert_(s.value, 100)
def testModule(self): c = config_get('modules', 'test') c.update('django') self.assertTrue(hasattr(self.c.value, 'get_version'))
from decimal import Decimal from django.utils.translation import ugettext_lazy as _ from livesettings.values import StringValue,ConfigurationGroup,BooleanValue,DecimalValue,MultipleStringValue from livesettings.functions import config_register_list,config_get SHIP_MODULES = config_get('SHIPPING', 'MODULES') SHIP_MODULES.add_choice(('shipping.modules.ups', 'UPS')) SHIPPING_GROUP = ConfigurationGroup('shipping.modules.ups', _('UPS Shipping Settings'), requires = SHIP_MODULES, ordering = 101) config_register_list( StringValue(SHIPPING_GROUP, 'XML_KEY', description=_("UPS XML Access Key"), help_text=_("XML Access Key Provided by UPS"), default=u""), StringValue(SHIPPING_GROUP, 'USER_ID', description=_("UPS User ID"), help_text=_("User ID provided by UPS site."), default=u""), StringValue(SHIPPING_GROUP, 'ACCOUNT', description=_("UPS Account Number"), help_text=_("UPS Account Number."),
def testOverriddenSetting(self): """Accessing an overridden setting should give the override value.""" c = config_get('overgroup', 's2') self.assertEqual(c.value, 100)
def test_two_checkouts_dont_duplicate_contact(self): """ Two checkouts with the same email address do not duplicate contacts Ticket #1264 [Invalid] """ tax = config_get('TAX', 'MODULE') tax.update('tax.modules.percent') pcnt = config_get('TAX', 'PERCENT') pcnt.update('10') shp = config_get('TAX', 'TAX_SHIPPING_PERCENT') shp.update(False) # First checkout self.test_cart_adding() response = self.client.post(reverse('satchmo_checkout-step1'), get_step1_post_data(self.US)) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-step2'), status_code=302, target_status_code=200) data = { 'credit_type': 'Visa', 'credit_number': '4485079141095836', 'month_expires': '1', 'year_expires': '2020', 'ccv': '552', 'shipping': 'FlatRate' } response = self.client.post(reverse('DUMMY_satchmo_checkout-step2'), data) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-step3'), status_code=302, target_status_code=200) response = self.client.get(reverse('DUMMY_satchmo_checkout-step3')) amount = smart_str('Shipping + ' + moneyfmt(Decimal('4.00'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Tax + ' + moneyfmt(Decimal('4.60'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Total = ' + moneyfmt(Decimal('54.60'))) self.assertContains(response, amount, count=1, status_code=200) response = self.client.post(reverse('DUMMY_satchmo_checkout-step3'), {'process': 'True'}) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-success'), status_code=302, target_status_code=200) # Second checkout self.test_cart_adding() response = self.client.post(reverse('satchmo_checkout-step1'), get_step1_post_data(self.US)) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-step2'), status_code=302, target_status_code=200) data = { 'credit_type': 'Visa', 'credit_number': '4485079141095836', 'month_expires': '1', 'year_expires': '2020', 'ccv': '552', 'shipping': 'FlatRate' } response = self.client.post(reverse('DUMMY_satchmo_checkout-step2'), data) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-step3'), status_code=302, target_status_code=200) response = self.client.get(reverse('DUMMY_satchmo_checkout-step3')) amount = smart_str('Shipping + ' + moneyfmt(Decimal('4.00'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Tax + ' + moneyfmt(Decimal('4.60'))) self.assertContains(response, amount, count=1, status_code=200) amount = smart_str('Total = ' + moneyfmt(Decimal('54.60'))) self.assertContains(response, amount, count=1, status_code=200) response = self.client.post(reverse('DUMMY_satchmo_checkout-step3'), {'process': 'True'}) self.assertRedirects(response, reverse('DUMMY_satchmo_checkout-success'), status_code=302, target_status_code=200) self.assertEqual(len(mail.outbox), 2) qs = Contact.objects.filter(email="*****@*****.**") # We expects that the contact do not duplicate self.assertEqual(len(qs), 1)