def setUp(self):
        # make request

        self.rf = MockRequest()
        self.session_key = '11111111111111111111111111111111'
        # make mock basket lines
        p1 = MockBasketLine('10.00', 2, 'test thing')
        p2 = MockBasketLine('2.00', 1, 'another')
        # make the checkout
        c = Checkout()
        c.session_id = self.session_key
        c.items = [p1, p2]
        c.item_total = Decimal('10.00')
        c.lines = 3
        c.paid = False
        c.save()
        self.checkout = c
        # lets be in dev mode
        settings.STRIPE_MODE = 'TEST'
        # store original so it can be set back later
        self.ORIGINAL_DEV_MODE = c_settings.STRIPE_MODE
        self.ORIGINAL_OUTCOME = c_settings.STRIPE_OUTCOME
        self.ORIGINAL_BASE_URL = c_settings.STRIPE_BASE_URL
        reload(c_settings)
        reload(stripe)
 def setUp(self):
     # store original so it can be set back later
     self.ORIGINAL_DEV_MODE = c_settings.STRIPE_MODE
     reload(stripe)
     # override some of the customer forms 
     settings.CCCHECKOUT_POSTAGE_MODELS = ()
     settings.CCCHECKOUT_CUSTOMER_FORM = None 
     settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     settings.CCCHECKOUT_PAYMENT_FORMS = ()
     settings.STRIPE_MODE = 'TEST'
     # set up the session
     reload(c_settings)
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # make request
     self.rf = MockRequest()
 def test_nonexistant_adapter(self):
     """ a non existant adapter raises an exception when the
     prepare_checkout decorator processes it"""
     ORIGINAL_ADAPTER = getattr(settings, 'CCCHECKOUT_ADAPTER', None)
     # add a non existant adapter
     settings.CCCHECKOUT_ADAPTER = 'certainly.borking'
     # set up the checkout
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # make request
     self.rf = MockRequest()
     # request the customer page and we have an exception
     request = self.rf.get(reverse('cccheckout:customer'))
     request.session['cccheckout'] = self.checkout
     # this will raise an exception
     self.assertRaises(Exception, customer, request)
示例#4
0
 def setUp(self):
     # override some of the customer forms 
     settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     settings.CCCHECKOUT_PAYMENT_FORMS = (
             'cccheckout.payments.stripe.forms.StripeForm',)
     # set up the session
     reload(c_settings)
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     # now add a customer 
     customer = Customer()
     customer.email = '*****@*****.**'
     customer.save()
     c.customer = customer
     c.save()
     self.checkout = c
     # make request
     self.rf = MockRequest()
示例#5
0
 def setUp(self):
     """set up the environment for the tests"""
     reload(c_settings)
     session_key = '11111111111111111111111111111111'
     settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     engine = import_module(settings.SESSION_ENGINE)
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'anotjer')
     # make a customer
     customer = Customer(delivery_country='GB')
     customer.save()
     # make a checkout on the session
     c = Checkout()
     c.session_id = session_key
     c.customer = customer
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # make request & add checkout
     self.rf = MockRequest()
     # add the postages
     line1 = Line(name='Test case line based postage')
     line1.save()
     country1  = LineCountry(
                     country='GB',
                     line = line1)
     country1.save()
     # add the tiers
     tier1 = LineTier(
                 minimum=1,
                 maximum=22,
                 price=Decimal('1.00'),
                 line=line1)
     tier1.save()
     # tier 2
     tier2 = LineTier(
                 minimum=23,
                 maximum=50,
                 price=Decimal('2.00'),
                 line=line1)
     tier2.save()
     # now the content types
     line_ct = ContentType.objects.get_for_model(line1)
     tier_ct = ContentType.objects.get_for_model(tier1)
     # set up the selfs
     self.line1 = line1
     self.country1 = country1
     self.tier1 = tier1
     self.tier2 = tier2
     self.line_ct = line_ct
     self.tier_ct = tier_ct
 def setUp(self):
     # make a checkout
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
 def setUp(self):
     # the checkout for stripe just needs to be present
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # store original so it can be set back later
     self.ORIGINAL_DEV_MODE = c_settings.STRIPE_MODE
     reload(stripe)
示例#8
0
 def setUp(self):
     # set up the session
     reload(c_settings)
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # make request
     self.rf = MockRequest()
 def setUp(self):
     # set the domain so we know what it is
     settings.DEFAULT_DOMAIN = 'example.com'
     reload(c_settings)
     # make a checkout
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
示例#10
0
 def setUp(self):
     # set up
     session_key = '11111111111111111111111111111111'
     settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     engine = import_module(settings.SESSION_ENGINE)
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'anotjer')
     # make a checkout on the session
     c = Checkout()
     c.session_id = session_key
     #c.items = MockQuerySet(items=[p1, p2])
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.save()
     self.checkout = c
     # make request & add checkout
     self.rf = MockRequest()
示例#11
0
 def setUp(self):
     # override some of the customer forms 
     settings.CCCHECKOUT_POSTAGE_MODELS = ()
     settings.CCCHECKOUT_ADAPTER = 'cccheckout.tests.mock.testcase_adapter'
     settings.CCCHECKOUT_PAYMENT_FORMS = ()
     # set up the session
     reload(c_settings)
     session_key = '11111111111111111111111111111111'
     # make mock basket lines
     p1 = MockBasketLine('10.00', 2, 'test thing')
     p2 = MockBasketLine('2.00', 1, 'another')
     # make the checkout
     c = Checkout()
     c.session_id = session_key
     c.items = [p1, p2]
     c.item_total = Decimal('10.00')
     c.lines = 3
     c.save()
     self.checkout = c
     # make request
     self.rf = MockRequest()
示例#12
0
 def setUp(self):
     """Ensure postage form returns something"""
     #
     # LINE 1
     #
     line1 = Line(name='Test case line based postage')
     line1.save()
     country1  = LineCountry(
                     country='GB',
                     line = line1)
     country1.save()
     # add the tiers
     tier1 = LineTier(
                 minimum=1,
                 maximum=4,
                 price=Decimal('1.00'),
                 line=line1
             )
     tier1.save()
     # tier 2
     tier2 = LineTier(
                 minimum=5,
                 maximum=8,
                 price=Decimal('2.00'),
                 line=line1
             )
     tier2.save()
     # tier 3
     tier3 = LineTier(
                 minimum=9,
                 maximum=20,
                 price=Decimal('3.00'),
                 line=line1
             )
     tier3.save()
     #
     #
     # LINE 2
     line2 = Line(name='Swanky case line based postage')
     line2.save()
     country2  = LineCountry(
                     country='GB',
                     line=line2)
     country2.save()
     # add the tiers
     tier4 = LineTier(
                 minimum=1,
                 maximum=8,
                 price=Decimal('5.00'),
                 line=line2
             )
     tier4.save()
     # tier 2
     tier5 = LineTier(
                 minimum=9,
                 maximum=20,
                 price=Decimal('10.00'),
                 line=line2
             )
     tier5.save()
     #
     #
     # the checkout
     customer = Customer(delivery_country='GB')
     customer.save()
     checkout = Checkout(
                 session_id='test',
                 customer=customer)
     checkout.save()
     # now the content types
     line_ct = ContentType.objects.get_for_model(line1)
     tier_ct = ContentType.objects.get_for_model(tier1)
     # set up the selfs
     self.checkout = checkout
     self.line1 = line1
     self.line2 = line2
     self.country1 = country1
     self.country2 = country2
     self.tier1 = tier1
     self.tier2 = tier2
     self.tier3 = tier3
     self.tier4 = tier4
     self.tier5 = tier5
     self.line_ct = line_ct
     self.tier_ct = tier_ct