def test_check(self): provider = Reference() @account_check def test(self, account): pass provider.test = test provider.test(provider, PaymentAccount(provider=PROVIDER_REFERENCE)) with self.assertRaises(ValueError): provider.test(provider, PaymentAccount(provider=PROVIDER_BOKU))
def test_create_bango(self, solselc, client): # Return a seller object without hitting Bango. solselc.return_value = SolitudeSeller.objects.create( resource_uri='selluri', user=self.user ) client.post_package.return_value = { 'resource_uri': 'zipzap', 'package_id': 123, } res = PaymentAccount.create_bango( self.user, {'account_name': 'Test Account'}) eq_(res.name, 'Test Account') eq_(res.user, self.user) eq_(res.seller_uri, 'selluri') eq_(res.bango_package_id, 123) eq_(res.uri, 'zipzap') client.post_package.assert_called_with( data={'supportEmailAddress': '*****@*****.**', 'paypalEmailAddress': '*****@*****.**', 'seller': 'selluri'}) client.post_bank_details.assert_called_with( data={'seller_bango': 'zipzap'})
def payments_accounts_add(request): form = forms_payments.BangoPaymentAccountForm(request.POST) if not form.is_valid(): return json_view.error(form.errors) try: obj = PaymentAccount.create_bango(request.amo_user, form.cleaned_data) except HttpClientError as e: log.error('Client error create Bango account; %s' % e) return http.HttpResponseBadRequest(json.dumps(e.content)) return {'pk': obj.pk, 'agreement-url': obj.get_agreement_url()}
def obj_create(self, bundle, request=None, **kwargs): try: bundle.obj = PaymentAccount.create_bango( request.amo_user, bundle.data) except HttpClientError as e: log.error('Client error create Bango account; %s' % e) raise ImmediateHttpResponse( http.HttpApplicationError(json.dumps(e.content))) except HttpServerError as e: log.error('Error creating Bango payment account; %s' % e) raise ImmediateHttpResponse(http.HttpApplicationError( _(u'Could not connect to payment server.'))) return bundle
def test_create_bango(self, solselc, client): solselc.return_value = Mock(resource_uri='selluri') client.post_package.return_value = {'resource_uri': 'zipzap'} res = PaymentAccount.create_bango( self.user, {'account_name': 'Test Account'}) eq_(res.name, 'Test Account') eq_(res.user, self.user) eq_(res.seller_uri, 'selluri') eq_(res.uri, 'zipzap') client.post_package.assert_called_with( data={'supportEmailAddress': '*****@*****.**', 'paypalEmailAddress': '*****@*****.**', 'seller': 'selluri'}) client.post_bank_details.assert_called_with( data={'seller_bango': 'zipzap'})
def test_create_bango(self): # Return a seller object without hitting Bango. self.client.api.bango.package.post.return_value = { 'resource_uri': 'zipzap', 'package_id': 123, } res = PaymentAccount.create_bango( self.user, {'account_name': 'Test Account'}) eq_(res.name, 'Test Account') eq_(res.user, self.user) eq_(res.seller_uri, 'selleruri') eq_(res.bango_package_id, 123) eq_(res.uri, 'zipzap') self.client.api.bango.package.post.assert_called_with( data={'paypalEmailAddress': '*****@*****.**', 'seller': 'selleruri'}) self.client.api.bango.bank.post.assert_called_with( data={'seller_bango': 'zipzap'})