Esempio n. 1
0
 def test_address_save_with_address_in_group(self, mock_save):
     self.request.POST = NEW_ADDRESS_POST
     self.request.POST['method'] = 0
     group = MagicMock()
     group.address = Address()
     group.get_delivery_methods.return_value = [DummyShipping(group)]
     step = ShippingStep(self.checkout, self.request, group)
     self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
     step.save()
     self.assertEqual(mock_save.call_count, 0)
Esempio n. 2
0
 def test_address_save_without_address(self, mock_save):
     self.request.POST = NEW_ADDRESS_POST
     self.request.POST['method'] = 0
     group = MagicMock()
     group.address = None
     checkout = Checkout(self.request)
     group.get_delivery_methods.return_value = [DummyShipping(group)]
     step = ShippingStep(checkout, self.request, group)
     self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
     step.save()
     self.assertEqual(mock_save.call_count, 0)
     grup_storage = checkout.get_group(str(step))
     self.assertEqual(type(grup_storage['address']), Address,
                      'Address instance expected')
Esempio n. 3
0
 def test_address_save_with_address_in_checkout(self, mock_save):
     self.request.POST = NEW_ADDRESS_POST
     self.request.POST['method'] = 0
     original_billing_address_data = {
         'first_name': 'Change',
         'last_name': 'Me',
         'id': 10
     }
     original_billing_address = Address(**original_billing_address_data)
     self.checkout.billing_address = original_billing_address
     group = MagicMock()
     group.address = None
     group.get_delivery_methods.return_value = [DummyShipping(group)]
     step = ShippingStep(self.checkout, self.request, group)
     self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
     step.save()
     self.assertEqual(mock_save.call_count, 0)
     self.assertEqual(self.checkout.billing_address,
                      Address(**original_billing_address_data))
     self.assertEqual(step.group['address'].id, None)
Esempio n. 4
0
 def get_delivery_methods(self):
     '''
     Returns shippable delivery methods.
     '''
     yield DummyShipping(self)