This repository has been archived by the owner on Jan 25, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow prices to be a list of dicts and make price optional in the tra…
…nsaction (bug 821511)
- Loading branch information
Andy McKay
committed
Dec 19, 2012
1 parent
d7f945c
commit 328c9cd
Showing
9 changed files
with
107 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import json | ||
from unittest import TestCase | ||
|
||
import mock | ||
from ..forms import CreateBankDetailsForm | ||
from .samples import good_bank_details | ||
from nose.tools import eq_, ok_ | ||
|
||
from ..forms import (CreateBankDetailsForm, | ||
CreateBillingConfigurationForm as BillingForm, | ||
PriceForm) | ||
from .samples import good_bank_details, good_billing_request | ||
|
||
|
||
@mock.patch('lib.bango.forms.URLField.clean') | ||
|
@@ -23,3 +28,46 @@ def test_iban(self, clean): | |
del self.bank['bankAccountNumber'] | ||
self.bank['bankAccountIban'] = 'foo' | ||
assert CreateBankDetailsForm(self.bank).is_valid() | ||
|
||
|
||
@mock.patch('lib.bango.forms.URLField.clean') | ||
class TestBilling(TestCase): | ||
|
||
def setUp(self): | ||
self.billing = good_billing_request.copy() | ||
self.billing['seller_product_bango'] = '/blah/' | ||
|
||
def test_form(self, clean): | ||
ok_(PriceForm({'amount': 1, 'currency': 'NZD'})) | ||
|
||
def test_billing(self, clean): | ||
ok_(BillingForm(self.billing).is_valid()) | ||
|
||
def test_no_json(self, clean): | ||
del self.billing['prices'] | ||
assert not BillingForm(self.billing).is_valid() | ||
|
||
def test_bad_json(self, clean): | ||
self.billing['prices'] = 'blargh' | ||
assert not BillingForm(self.billing).is_valid() | ||
|
||
self.billing['prices'] = json.dumps(['foo']) | ||
assert not BillingForm(self.billing).is_valid() | ||
|
||
def test_no_prices(self, clean): | ||
self.billing['prices'] = [] | ||
form = BillingForm(self.billing) | ||
form.is_valid() | ||
eq_(form.errors['prices'], ['This field is required.']) | ||
|
||
def test_price_error(self, clean): | ||
self.billing['prices'] = [{'amount': 1, 'currency': 'FOO'}] | ||
form = BillingForm(self.billing) | ||
form.is_valid() | ||
ok_('Select a valid choice' in form.errors['prices'][0]) | ||
|
||
def test_iterate(self, clean): | ||
form = BillingForm(self.billing) | ||
form.is_valid() | ||
for price in form.cleaned_data['prices']: | ||
ok_(price.is_valid()) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
andymckay
Contributor
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE transaction MODIFY amount decimal(9,2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
why do you like this over
assert
?