def test_invalid_credit_card_displays_errors(self): with patch.object(SiteSignupForm, 'create_payment_profile') as mock_method: mock_method.side_effect = PaymentGatewayError() form = SiteSignupForm(self.data, account=self.account, plan=self.plan) 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())
def signup(request, reseller_secret, plan_secret): account = get_object_or_404(Account, secret=reseller_secret) plan = get_object_or_404(account.plan_set, secret=plan_secret) if request.method == 'POST': form = SiteSignupForm(request.POST, account=account, plan=plan, error_class=SpanErrorList) if form.is_valid(): form.save() return HttpResponseRedirect(unicode(form.site) + reverse('dashboard', urlconf='tiger.urls')) else: form = SiteSignupForm(account=account, plan=plan) return direct_to_template(request, template='tiger/signup.html', extra_context={ 'form': form, 'plan': plan })
def test_valid_form_creates_manager_account(self): with patch.object(SiteSignupForm, 'create_payment_profile') as mock_method: mock_method.return_value = ['foo', 'bar'] form = SiteSignupForm(self.data, account=self.account, plan=self.plan) form.full_clean() self.assertTrue(form.create_payment_profile.called) site = form.save() site.plan |should| equal_to(self.plan) site.account |should| equal_to(self.account) site.credit_card |should_not| be(None) card = site.credit_card self.assertEquals(card.customer_id, 'foo') self.assertEquals(card.subscription_id, 'bar') self.assertEquals(card.card_number, '5678') self.assertTrue(site.managed) self.assertEquals(len(mail.outbox), 1) self.assertTrue(self.client.login(email=site.user.email, password='******', site=site))
def test_valid_form_creates_manager_account(self): with patch.object(SiteSignupForm, 'create_payment_profile') as mock_method: mock_method.return_value = ['foo', 'bar'] form = SiteSignupForm(self.data, account=self.account, plan=self.plan) form.full_clean() self.assertTrue(form.create_payment_profile.called) site = form.save() site.plan | should | equal_to(self.plan) site.account | should | equal_to(self.account) site.credit_card | should_not | be(None) card = site.credit_card self.assertEquals(card.customer_id, 'foo') self.assertEquals(card.subscription_id, 'bar') self.assertEquals(card.card_number, '5678') self.assertTrue(site.managed) self.assertEquals(len(mail.outbox), 1) self.assertTrue( self.client.login(email=site.user.email, password='******', site=site))
def signup(request, reseller_secret, plan_secret): account = get_object_or_404(Account, secret=reseller_secret) plan = get_object_or_404(account.plan_set, secret=plan_secret) if request.method == 'POST': form = SiteSignupForm(request.POST, account=account, plan=plan, error_class=SpanErrorList) if form.is_valid(): form.save() return HttpResponseRedirect( unicode(form.site) + reverse('dashboard', urlconf='tiger.urls')) else: form = SiteSignupForm(account=account, plan=plan) return direct_to_template(request, template='tiger/signup.html', extra_context={ 'form': form, 'plan': plan })