コード例 #1
0
    def testPercent(self):
        """Test percent tax without shipping"""
        cache_delete()
        tax = config_get('TAX', 'MODULE')
        tax.update('satchmo.tax.modules.percent')
        pcnt = config_get('TAX', 'PERCENT')
        pcnt.update('10')
        shp = config_get('TAX', 'TAX_SHIPPING')
        shp.update(False)

        order = make_test_order('US', 'TX')

        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('10.00'))
        # 100 + 10 shipping + 10 tax
        self.assertEqual(price, Decimal('120.00'))

        taxes = order.taxes.all()
        self.assertEqual(1, len(taxes))
        self.assertEqual(taxes[0].tax, Decimal('10.00'))
        self.assertEqual(taxes[0].description, r'10%')
コード例 #2
0
ファイル: tests.py プロジェクト: sankroh/satchmo
    def test_checkout(self):
        """
        Run through a full checkout process
        """
        cache_delete()
        tax = config_get("TAX", "MODULE")
        tax.update("satchmo.tax.modules.percent")
        pcnt = config_get("TAX", "PERCENT")
        pcnt.update("10")
        shp = config_get("TAX", "TAX_SHIPPING")
        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": "2009",
            "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"))
        self.assertContains(
            response, smart_str("Shipping + %s4.00" % config_value("SHOP", "CURRENCY")), count=1, status_code=200
        )
        self.assertContains(
            response, smart_str("Tax + %s4.60" % config_value("SHOP", "CURRENCY")), count=1, status_code=200
        )
        self.assertContains(
            response, smart_str("Total = %s54.60" % config_value("SHOP", "CURRENCY")), 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 pdf generation
        response = self.client.get("/admin/print/invoice/1/")
        self.assertContains(response, "reportlab", status_code=200)
        response = self.client.get("/admin/print/packingslip/1/")
        self.assertContains(response, "reportlab", status_code=200)
        response = self.client.get("/admin/print/shippinglabel/1/")
        self.assertContains(response, "reportlab", status_code=200)
コード例 #3
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
    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")
        response = self.client.get(prefix+'/product/dj-rocks/')
        self.assertContains(response, "Django Rocks shirt", count=2, status_code=200)
        response = self.client.post(prefix+'/cart/add/', { "productname" : "dj-rocks",
                                                      "1" : "L",
                                                      "2" : "BL",
                                                      "quantity" : 2})
        self.assertRedirects(response, prefix + '/cart/',
            status_code=302, target_status_code=200)
        response = self.client.get(prefix+'/cart/')
        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(prefix+'/cart/add/', { "productname" : "dj-rocks",
                                                      "1" : "L",
                                                      "2" : "BL",
                                                      "quantity" : 10})
        self.assertRedirects(response, prefix + '/cart/',
            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)
コード例 #4
0
ファイル: tests.py プロジェクト: juderino/jelly-roll
    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('satchmo.tax.modules.no')
        c = Contact(first_name="Jim", last_name="Tester", 
            role="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
コード例 #5
0
    def testDuplicateAdminAreas(self):
        """Test the situation where we have multiple adminareas with the same name"""
        cache_delete()
        tax = config_get('TAX', 'MODULE')
        tax.update('satchmo.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'))
コード例 #6
0
def make_urlpatterns():
    patterns = []
    for key in config_value('PAYMENT', 'MODULES'):
        cfg = config_get(key, 'MODULE')
        modulename = cfg.editor_value
        urlmodule = "%s.urls" % modulename
        patterns.append(url(config_value(key, 'URL_BASE'), [urlmodule]))
    return tuple(patterns)
コード例 #7
0
ファイル: urls.py プロジェクト: juderino/jelly-roll
def make_urlpatterns():
    patterns = []
    for key in config_value('PAYMENT', 'MODULES'):
        cfg = config_get(key, 'MODULE')
        modulename = cfg.editor_value
        urlmodule = "%s.urls" % modulename
        patterns.append(url(config_value(key, 'URL_BASE'), [urlmodule, modulename, '']))
    return tuple(patterns)
コード例 #8
0
    def testAreaCountries(self):
        """Test Area tax module"""
        cache_delete()
        tax = config_get('TAX', 'MODULE')
        tax.update('satchmo.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'))
コード例 #9
0
ファイル: satchmo_checkout.py プロジェクト: jimmcgaw/levicci
def payment_label(value):
    """convert a payment key into its translated text"""
    
    payments = config_get("PAYMENT", "MODULES")
    for mod in payments.value:
        config = config_get_group(mod)
        if config.KEY.value == value:
            return translation.ugettext(config.LABEL)
    return value.capitalize()
コード例 #10
0
ファイル: tests.py プロジェクト: sankroh/satchmo
    def test_custom_product(self):
        """
        Verify that the custom product is working as expected.
        """
        pm = config_get("PRODUCT", "PRODUCT_TYPES")
        pm.update(
            [
                "product::ConfigurableProduct",
                "product::ProductVariation",
                "product::CustomProduct",
                "product::SubscriptionProduct",
            ]
        )

        response = self.client.get(prefix + "/")
        self.assertContains(response, "Computer", count=1)
        response = self.client.get(prefix + "/product/satchmo-computer/")
        self.assertContains(response, "Memory", count=1)
        self.assertContains(response, "Case", count=1)
        self.assertContains(response, "Monogram", count=1)
        response = self.client.post(
            prefix + "/cart/add/",
            {"productname": "satchmo-computer", "5": "1.5gb", "6": "mid", "custom_monogram": "CBM", "quantity": 1},
        )
        self.assertRedirects(response, prefix + "/cart/", status_code=302, target_status_code=200)
        response = self.client.get(prefix + "/cart/")
        self.assertContains(response, '/satchmo-computer/">satchmo computer', count=1, status_code=200)
        self.assertContains(response, smart_str("%s168.00" % config_value("SHOP", "CURRENCY")), count=3)
        self.assertContains(response, smart_str("Monogram: CBM  %s10.00" % config_value("SHOP", "CURRENCY")), count=1)
        self.assertContains(
            response, smart_str("Case - External Case: Mid  %s10.00" % config_value("SHOP", "CURRENCY")), count=1
        )
        self.assertContains(
            response, smart_str("Memory - Internal RAM: 1.5 GB  %s25.00" % config_value("SHOP", "CURRENCY")), count=1
        )
        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": "2012",
            "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"))
        self.assertContains(
            response,
            smart_str("satchmo computer - %s168.00" % config_value("SHOP", "CURRENCY")),
            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)
コード例 #11
0
def payment_label(value):
    """convert a payment key into its translated text"""

    payments = config_get("PAYMENT", "MODULES")
    for mod in payments.value:
        config = config_get_group(mod)
        if config.KEY.value == value:
            return translation.ugettext(unicode(config.LABEL))
    return value.capitalize()
コード例 #12
0
    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")
        response = self.client.get(prefix + '/product/dj-rocks/')
        self.assertContains(response,
                            "Django Rocks shirt",
                            count=2,
                            status_code=200)
        response = self.client.post(prefix + '/cart/add/', {
            "productname": "dj-rocks",
            "1": "L",
            "2": "BL",
            "quantity": 2
        })
        self.assertRedirects(response,
                             prefix + '/cart/',
                             status_code=302,
                             target_status_code=200)
        response = self.client.get(prefix + '/cart/')
        self.assertContains(response,
                            "Django Rocks shirt (Large/Blue)",
                            count=2,
                            status_code=200)
        response = self.client.get(url('satchmo_checkout-step1'))
        self.assertContains(response, "Billing Address", 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(prefix + '/cart/add/', {
            "productname": "dj-rocks",
            "1": "L",
            "2": "BL",
            "quantity": 10
        })
        self.assertRedirects(response,
                             prefix + '/cart/',
                             status_code=302,
                             target_status_code=200)
        response = self.client.get(url('satchmo_checkout-step1'))
        self.assertContains(response, "Billing Address", status_code=200)
コード例 #13
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
    def testPercentShipping(self):
        """Test percent tax with shipping"""
        cache_delete()
        tax = config_get('TAX','MODULE')
        tax.update('satchmo.tax.modules.percent')
        pcnt = config_get('TAX', 'PERCENT')
        pcnt.update('10')
        shp = config_get('TAX', 'TAX_SHIPPING')
        shp.update(False)

        order = make_test_order('US', 'TX')
        shp.update(True)
        order.recalculate_total(save=False)
        price = order.total
        tax = order.tax
        
        self.assertEqual(tax, Decimal('11.00'))
        # 100 + 10 shipping + 11 tax
        self.assertEqual(price, Decimal('121.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('10.00'))
        self.assertEqual(tmain.description, r'10%')
        self.assertEqual(tship.tax, Decimal('1.00'))
        self.assertEqual(tship.description, 'Shipping')
        
        
        
コード例 #14
0
    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('satchmo.tax.modules.no')
        c = Contact(first_name="Jim",
                    last_name="Tester",
                    role="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
コード例 #15
0
    def testPercentShipping(self):
        """Test percent tax with shipping"""
        cache_delete()
        tax = config_get('TAX', 'MODULE')
        tax.update('satchmo.tax.modules.percent')
        pcnt = config_get('TAX', 'PERCENT')
        pcnt.update('10')
        shp = config_get('TAX', 'TAX_SHIPPING')
        shp.update(False)

        order = make_test_order('US', 'TX')
        shp.update(True)
        order.recalculate_total(save=False)
        price = order.total
        tax = order.tax

        self.assertEqual(tax, Decimal('11.00'))
        # 100 + 10 shipping + 11 tax
        self.assertEqual(price, Decimal('121.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('10.00'))
        self.assertEqual(tmain.description, r'10%')
        self.assertEqual(tship.tax, Decimal('1.00'))
        self.assertEqual(tship.description, 'Shipping')
コード例 #16
0
ファイル: config.py プロジェクト: juderino/jelly-roll
def config_tax():
    TAX_MODULE = config_get('TAX', 'MODULE')
    TAX_MODULE.add_choice(('satchmo.tax.modules.area', _('By Country/Area')))
    TAX_GROUP = config_get_group('TAX')

    _tax_classes = []
    ship_default = ""

    try:
        for tax in TaxClass.objects.all():
            _tax_classes.append((tax.title, tax))
            if "ship" in tax.title.lower():
                ship_default = tax.title
    except:
        log.warn("Ignoring database error retrieving tax classes - OK if you are in syncdb.")

    if ship_default == "" and len(_tax_classes) > 0:
        ship_default = _tax_classes[0][0]

    config_register(
        BooleanValue(
            TAX_GROUP,
            'TAX_SHIPPING',
            description=_("Tax Shipping?"),
            requires=TAX_MODULE,
            requiresvalue='satchmo.tax.modules.area',
            default=False
        )
    )

    config_register(
        StringValue(
            TAX_GROUP,
            'TAX_CLASS',
            description=_("TaxClass for shipping"),
            help_text=_("Select a TaxClass that should be applied for shipments."),
            default=ship_default,
            choices=_tax_classes
        )
    )
コード例 #17
0
def config_tax():
    TAX_MODULE = config_get('TAX', 'MODULE')
    TAX_MODULE.add_choice(('satchmo.tax.modules.area', _('By Country/Area')))
    TAX_GROUP = config_get_group('TAX')

    _tax_classes = []
    ship_default = ""

    try:
        for tax in TaxClass.objects.all():
            _tax_classes.append((tax.title, tax))
            if "ship" in tax.title.lower():
                ship_default = tax.title
    except:
        log.warn(
            "Ignoring database error retrieving tax classes - OK if you are in syncdb."
        )

    if ship_default == "" and len(_tax_classes) > 0:
        ship_default = _tax_classes[0][0]

    config_register(
        BooleanValue(TAX_GROUP,
                     'TAX_SHIPPING',
                     description=_("Tax Shipping?"),
                     requires=TAX_MODULE,
                     requiresvalue='satchmo.tax.modules.area',
                     default=False))

    config_register(
        StringValue(
            TAX_GROUP,
            'TAX_CLASS',
            description=_("TaxClass for shipping"),
            help_text=_(
                "Select a TaxClass that should be applied for shipments."),
            default=ship_default,
            choices=_tax_classes))
コード例 #18
0
ファイル: config.py プロジェクト: typerlc/artlab_satchmo
from satchmo.configuration import config_get

LANGUAGES_AVAILABLE = config_get("LANGUAGE", "LANGUAGES_AVAILABLE")

LANGUAGES_AVAILABLE.add_choice(("en", "English"))
LANGUAGES_AVAILABLE.add_choice(("ja", "Japanese"))
コード例 #19
0
from satchmo.configuration import config_get

LANGUAGES_AVAILABLE = config_get('LANGUAGE', 'LANGUAGES_AVAILABLE')

LANGUAGES_AVAILABLE.add_choice(('es', 'Spanish'))
コード例 #20
0
ファイル: config.py プロジェクト: juderino/jelly-roll
from django.utils.translation import ugettext_lazy as _
from satchmo.configuration import (
    config_get,
    config_register_list,
    ConfigurationGroup,
    DecimalValue,
    MultipleStringValue
)
from satchmo.l10n.models import Country

SHIP_MODULES = config_get('SHIPPING', 'MODULES')
SHIP_MODULES.add_choice(('satchmo.shipping.modules.royalmailcontract', _('Royal Mail Contract')))

SHIPPING_GROUP = ConfigurationGroup('satchmo.shipping.modules.royalmailcontract',
                                    _('Royal Mail Contract Shipping Settings'),
                                    requires=SHIP_MODULES,
                                    ordering=101)


config_register_list(
    DecimalValue(SHIPPING_GROUP,
                 'PACKING_FEE',
                 description=_("Packing Fee"),
                 requires=SHIP_MODULES,
                 requiresvalue='satchmo.shipping.modules.royalmailcontract',
                 default="0.30"),

    DecimalValue(SHIPPING_GROUP,
                 'MAX_WEIGHT_PER_ITEM',
                 description=_("Max weight per item in Kgs (packet)"),
                 help_text=_("The orders weight is rounded up and divided by this and multiplied by the per item price"),
コード例 #21
0
from django.utils.translation import ugettext_lazy as _
from satchmo.configuration import (config_get, config_register_list,
                                   ConfigurationGroup, DecimalValue,
                                   MultipleStringValue)
from satchmo.l10n.models import Country

SHIP_MODULES = config_get('SHIPPING', 'MODULES')
SHIP_MODULES.add_choice(
    ('satchmo.shipping.modules.royalmailcontract', _('Royal Mail Contract')))

SHIPPING_GROUP = ConfigurationGroup(
    'satchmo.shipping.modules.royalmailcontract',
    _('Royal Mail Contract Shipping Settings'),
    requires=SHIP_MODULES,
    ordering=101)

config_register_list(
    DecimalValue(SHIPPING_GROUP,
                 'PACKING_FEE',
                 description=_("Packing Fee"),
                 requires=SHIP_MODULES,
                 requiresvalue='satchmo.shipping.modules.royalmailcontract',
                 default="0.30"),
    DecimalValue(
        SHIPPING_GROUP,
        'MAX_WEIGHT_PER_ITEM',
        description=_("Max weight per item in Kgs (packet)"),
        help_text=
        _("The orders weight is rounded up and divided by this and multiplied by the per item price"
          ),
        requires=SHIP_MODULES,
コード例 #22
0
ファイル: tests.py プロジェクト: abrar78/satchmo
 def setUp(self):
     cfg = config_get('NEWSLETTER', 'MODULE')
     cfg.update('satchmo.newsletter.simple')
     self.client = Client()
コード例 #23
0
ファイル: tests.py プロジェクト: yusufbs/satchmo
 def setUp(self):
     cfg = config_get("NEWSLETTER", "MODULE")
     cfg.update("satchmo.newsletter.simple")
     self.client = Client()
コード例 #24
0
    def test_custom_product(self):
        """
        Verify that the custom product is working as expected.
        """
        pm = config_get("PRODUCT", "PRODUCT_TYPES")
        pm.update([
            "product::ConfigurableProduct", "product::ProductVariation",
            "product::CustomProduct", "product::SubscriptionProduct"
        ])

        response = self.client.get(prefix + "/")
        self.assertContains(response, "Computer", count=1)
        response = self.client.get(prefix + "/product/satchmo-computer/")
        self.assertContains(response, "Memory", count=1)
        self.assertContains(response, "Case", count=1)
        self.assertContains(response, "Monogram", count=1)
        response = self.client.post(
            prefix + '/cart/add/', {
                "productname": "satchmo-computer",
                "5": "1.5gb",
                "6": "mid",
                "custom_monogram": "CBM",
                "quantity": 1
            })
        self.assertRedirects(response,
                             prefix + '/cart/',
                             status_code=302,
                             target_status_code=200)
        response = self.client.get(prefix + '/cart/')
        self.assertContains(response,
                            '/satchmo-computer/">satchmo computer',
                            status_code=200)
        self.assertContains(response,
                            smart_str("%s168.00" %
                                      config_value('SHOP', 'CURRENCY')),
                            count=4)
        self.assertContains(response,
                            smart_str("Monogram: CBM  %s10.00" %
                                      config_value('SHOP', 'CURRENCY')),
                            count=1)
        self.assertContains(response,
                            smart_str("Case - External Case: Mid  %s10.00" %
                                      config_value('SHOP', 'CURRENCY')),
                            count=1)
        self.assertContains(
            response,
            smart_str("Memory - Internal RAM: 1.5 GB  %s25.00" %
                      config_value('SHOP', 'CURRENCY')),
            count=1)
        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': '2012',
            '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'))
        self.assertContains(response,
                            smart_str("satchmo computer - %s168.00" %
                                      config_value('SHOP', 'CURRENCY')),
                            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)
コード例 #25
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
 def setUp(self):
     cfg = config_get('NEWSLETTER', 'MODULE')
     cfg.update('satchmo.newsletter.simple')
     self.client = Client()