def test_select_method(self): ''' Test the BaseShippingStep managment form when method is set to 'select' and user isn't authenticated. ''' self.request.POST = SELECT_ADDRESS_POST step = BaseShippingStep(self.checkout, self.request, self.address) self.assertFalse(step.forms_are_valid(), 'Forms should not validate.')
def test_new_method(self): ''' Test the BaseShippingStep managment form when method is set to 'new' and user isn't authenticated. ''' self.request.POST = NEW_ADDRESS_POST step = BaseShippingStep(self.checkout, self.request, self.address) self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.') self.assertEqual(step.address.first_name, 'Test')
def test_select_with_user_method(self): ''' Test the BaseShippingStep managment form when method is set to 'select' and user is authenticated. ''' user = self.request.user self.request.POST = SELECT_ADDRESS_POST user.is_authenticated.return_value = True user.address_book.all.__iter__.return_value = [self.address] step = BaseShippingStep(self.checkout, self.request, self.address) self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')