[8146] | 1 | """Tests for waeup.kofa.schema fields. |
---|
| 2 | """ |
---|
| 3 | import unittest |
---|
| 4 | from zope.interface.verify import verifyClass, verifyObject |
---|
[8166] | 5 | from zope.schema.interfaces import IDate |
---|
[8171] | 6 | from waeup.kofa.schema import FormattedDate, PhoneNumber |
---|
| 7 | from waeup.kofa.schema.interfaces import IFormattedDate, IPhoneNumber |
---|
[8146] | 8 | |
---|
| 9 | class FormattedDateTests(unittest.TestCase): |
---|
| 10 | # Tests for FormattedDate field. |
---|
| 11 | |
---|
| 12 | def test_iface(self): |
---|
| 13 | # make sure we fullfill interface contracts |
---|
| 14 | obj = FormattedDate() |
---|
| 15 | verifyClass(IDate, FormattedDate) |
---|
| 16 | verifyClass(IFormattedDate, FormattedDate) |
---|
| 17 | verifyObject(IDate, obj) |
---|
| 18 | verifyObject(IFormattedDate, obj) |
---|
| 19 | return |
---|
| 20 | |
---|
| 21 | def test_defaults(self): |
---|
| 22 | # we get expected default values for dates. |
---|
| 23 | obj = FormattedDate() |
---|
| 24 | self.assertEqual(obj.show_year, False) |
---|
[8151] | 25 | self.assertEqual(obj.date_format, None) |
---|
[8146] | 26 | return |
---|
| 27 | |
---|
| 28 | def test_attribs(self): |
---|
| 29 | # we can set the promised attributes. |
---|
| 30 | obj = FormattedDate(show_year=True, date_format='%d.%m.%Y') |
---|
| 31 | self.assertEqual(obj.show_year, True) |
---|
| 32 | self.assertEqual(obj.date_format, '%d.%m.%Y') |
---|
| 33 | return |
---|
[8171] | 34 | |
---|
| 35 | class PhoneNumberTests(unittest.TestCase): |
---|
| 36 | # Tests for PhoneNumber field |
---|
| 37 | def test_iface(self): |
---|
| 38 | # make sure we fullfill interface contracts |
---|
| 39 | obj = PhoneNumber() |
---|
| 40 | verifyClass(IPhoneNumber, PhoneNumber) |
---|
| 41 | verifyObject(IPhoneNumber, obj) |
---|
| 42 | return |
---|