1 | """Tests for waeup.kofa.schema fields. |
---|
2 | """ |
---|
3 | import unittest |
---|
4 | from zope.interface.verify import verifyClass, verifyObject |
---|
5 | from zope.schema.interfaces import IDate |
---|
6 | from waeup.kofa.schema import FormattedDate, PhoneNumber |
---|
7 | from waeup.kofa.schema.interfaces import IFormattedDate, IPhoneNumber |
---|
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) |
---|
25 | self.assertEqual(obj.date_format, None) |
---|
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 |
---|
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 |
---|