예제 #1
0
 def test_invalid_credit_card_displays_errors(self):
     with patch.object(CreateResellerAccountForm, 'create_payment_profile') as mock_method:
         mock_method.side_effect = PaymentGatewayError()
         form = CreateResellerAccountForm(self.data)
         self.assertFalse(form.is_valid())
         self.assertTrue(form.create_payment_profile.called)
         self.assertTrue('Unable to process your credit card.' in form.non_field_errors())
예제 #2
0
 def test_invalid_credit_card_displays_errors(self):
     with patch.object(CreateResellerAccountForm,
                       'create_payment_profile') as mock_method:
         mock_method.side_effect = PaymentGatewayError()
         form = CreateResellerAccountForm(self.data)
         self.assertFalse(form.is_valid())
         self.assertTrue(form.create_payment_profile.called)
         self.assertTrue('Unable to process your credit card.' in
                         form.non_field_errors())
예제 #3
0
def signup(request):
    if request.method == "POST":
        form = CreateResellerAccountForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse("auth_login"))
    else:
        form = CreateResellerAccountForm()
    return direct_to_template(request, template="sales/signup.html", extra_context={"form": form})
예제 #4
0
 def test_valid_form_creates_manager_account(self):
     with patch.object(CreateResellerAccountForm, 'create_payment_profile') as mock_method:
         mock_method.return_value = ['foo', 'bar']
         form = CreateResellerAccountForm(self.data)
         form.full_clean()
         self.assertTrue(form.create_payment_profile.called)
         account = form.save()
         account.credit_card |should_not| be(None)
         card = account.credit_card
         self.assertEquals(card.customer_id, 'foo')
         self.assertEquals(card.subscription_id, 'bar')
         self.assertEquals(card.card_number, '5678')
         self.assertTrue(account.manager)
         self.assertEquals(len(mail.outbox), 1)
         self.assertTrue(self.client.login(email=account.user.email, password='******'))
예제 #5
0
 def test_valid_form_creates_manager_account(self):
     with patch.object(CreateResellerAccountForm,
                       'create_payment_profile') as mock_method:
         mock_method.return_value = ['foo', 'bar']
         form = CreateResellerAccountForm(self.data)
         form.full_clean()
         self.assertTrue(form.create_payment_profile.called)
         account = form.save()
         account.credit_card | should_not | be(None)
         card = account.credit_card
         self.assertEquals(card.customer_id, 'foo')
         self.assertEquals(card.subscription_id, 'bar')
         self.assertEquals(card.card_number, '5678')
         self.assertTrue(account.manager)
         self.assertEquals(len(mail.outbox), 1)
         self.assertTrue(
             self.client.login(email=account.user.email,
                               password='******'))
예제 #6
0
파일: views.py 프로젝트: tonomuniz/tiger
def signup(request):
    if request.method == 'POST':
        form = CreateResellerAccountForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('auth_login'))
    else:
        form = CreateResellerAccountForm()
    return direct_to_template(request,
                              template='sales/signup.html',
                              extra_context={'form': form})