def test_buyer(self): buyer = Buyer.objects.create(uuid="sample:uid") data = self.get_data() data["buyer"] = buyer.uuid form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data["preapproval"], "")
def test_duplicate_uuid(self): PaypalTransaction.objects.create(seller=self.paypal, amount=5, uuid='sample:uuid') data = self.get_data() data['uuid'] = 'sample:uuid' form = PayValidation(data) assert not form.is_valid(), form.errors
def test_buyer(self): buyer = Buyer.objects.create(uuid='sample:uid') data = self.get_data() data['buyer'] = buyer.uuid form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data['preapproval'], '')
def test_duplicate_uuid(self): Transaction.objects.create(seller=self.paypal, amount=5, uuid='sample:uuid') data = self.get_data() data['uuid'] = 'sample:uuid' form = PayValidation(data) assert not form.is_valid(), form.errors
def test_buyer_preapproval_ignored(self): buyer = Buyer.objects.create(uuid='sample:uid') BuyerPaypal.objects.create(buyer=buyer, key='foo') data = self.get_data() data['use_preapproval'] = False data['buyer'] = buyer.uuid form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data['preapproval'], '')
def test_buyer_preapproval_ignored(self): buyer = Buyer.objects.create(uuid="sample:uid") BuyerPaypal.objects.create(buyer=buyer, key="foo") data = self.get_data() data["use_preapproval"] = False data["buyer"] = buyer.uuid form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data["preapproval"], "")
def obj_create(self, bundle, request, **kwargs): form = PayValidation(bundle.data) if not form.is_valid(): raise self.form_errors(form) paypal = get_client() # TODO: there might be a lot more we can do here. bundle.data = paypal.get_pay_key(*form.args(), **form.kwargs()) create.send(sender=self, bundle=bundle, form=form.cleaned_data) return bundle
def test_seller(self): form = PayValidation(self.get_data()) assert form.is_valid() eq_(form.cleaned_data['seller_email'], '*****@*****.**')
def test_buyer_optional(self): data = self.get_data() data['buyer'] = 'not:there:uid' form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data['preapproval'], '')
def test_no_seller(self): data = self.get_data() data['seller'] = 'foo' assert not PayValidation(data).is_valid()
def test_currency(self): form = PayValidation(self.get_data()) assert form.is_valid() eq_(form.cleaned_data["currency"], "USD")
def test_empty_paypal(self): self.paypal.paypal_id = '' self.paypal.save() assert not PayValidation(self.get_data()).is_valid()
def test_currency(self): form = PayValidation(self.get_data()) assert form.is_valid() eq_(form.cleaned_data['currency'], 'USD')
def test_buyer_optional(self): data = self.get_data() data["buyer"] = "not:there:uid" form = PayValidation(data) assert form.is_valid(), form.errors eq_(form.cleaned_data["preapproval"], "")
def test_no_paypal(self): self.paypal.delete() assert not PayValidation(self.get_data()).is_valid()