source: main/waeup.kofa/branches/0.2/src/waeup/kofa/schema/tests/test_fields.py @ 17931

Last change on this file since 17931 was 8171, checked in by uli, 13 years ago

Add PhoneNumber? schema field and register PhoneWidget? as default edit widget for it.

File size: 1.4 KB
Line 
1"""Tests for waeup.kofa.schema fields.
2"""
3import unittest
4from zope.interface.verify import verifyClass, verifyObject
5from zope.schema.interfaces import IDate
6from waeup.kofa.schema import FormattedDate, PhoneNumber
7from waeup.kofa.schema.interfaces import IFormattedDate, IPhoneNumber
8
9class 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
35class 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
Note: See TracBrowser for help on using the repository browser.