]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/tests/model/test_currency_validator.py
more test coverage
[bluechips.git] / bluechips / tests / model / test_currency_validator.py
1 from unittest import TestCase
2 from formencode import Invalid
3
4 from bluechips.model import types
5
6 class TestCurrencyValidator(TestCase):
7     def setUp(self):
8         self.v = types.CurrencyValidator()
9
10     def test_currency_validator_good(self):
11         assert (self.v.to_python('12.34') ==
12                 types.Currency('12.34'))
13
14     def test_currency_validator_nonzero(self):
15         try:
16             self.v.to_python('0')
17         except Invalid:
18             pass
19
20     def test_currency_validator_precision(self):
21         try:
22             self.v.to_python('12.345')
23         except Invalid:
24             pass
25
26     def test_currency_validator_amount(self):
27         try:
28             self.v.to_python('foo')
29         except Invalid:
30             pass