Changeset 8213


Ignore:
Timestamp:
19 Apr 2012, 12:40:10 (13 years ago)
Author:
uli
Message:

Converter tests are in bad shape. Add at least basic stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_converters.py

    r7932 r8213  
    2222import shutil
    2323import tempfile
     24import unittest
    2425from zope import schema
    2526from zope.component import provideUtility
     
    2930from zope.formlib import form
    3031from zope.interface import (
    31     Interface, implements, invariant, Invalid, implementedBy)
     32    Interface, implements, invariant, Invalid, implementedBy, verify)
    3233
    3334from waeup.kofa.app import University
    3435from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3536from waeup.kofa.interfaces import (
    36     SimpleKofaVocabulary, SubjectSource, GradeSource)
     37    SimpleKofaVocabulary, SubjectSource, GradeSource, IFieldConverter)
    3738from waeup.kofa.schoolgrades import ResultEntryField
    3839from waeup.kofa.university import Faculty
    39 from waeup.kofa.utils.converters import IObjectConverter
     40from waeup.kofa.utils.converters import (
     41    IObjectConverter, IFieldConverter, DefaultFieldConverter,
     42    ListFieldConverter, PhoneNumberFieldConverter, ResultEntryConverter,
     43    DefaultObjectConverter)
    4044from waeup.kofa.utils.helpers import attrs_to_fields
    4145
     
    125129        return implementedBy(Faculty)
    126130
     131class FieldConverterTests(unittest.TestCase):
     132
     133    def test_iface(self):
     134        # make sure we fullfill interface contracts
     135        obj1 = DefaultFieldConverter(None)
     136        obj2 = ListFieldConverter(None)
     137        obj3 = PhoneNumberFieldConverter(None)
     138        obj4 = ResultEntryConverter(None)
     139        verify.verifyObject(IFieldConverter, obj1)
     140        verify.verifyObject(IFieldConverter, obj2)
     141        verify.verifyObject(IFieldConverter, obj3)
     142        verify.verifyObject(IFieldConverter, obj4)
     143        verify.verifyClass(IFieldConverter, DefaultFieldConverter)
     144        verify.verifyClass(IFieldConverter, ListFieldConverter)
     145        verify.verifyClass(IFieldConverter, PhoneNumberFieldConverter)
     146        verify.verifyClass(IFieldConverter, ResultEntryConverter)
     147        return
     148
    127149class ConverterTests(FunctionalTestCase):
    128150
     
    153175        shutil.rmtree(self.dc_root)
    154176        clearSite()
     177        return
     178
     179    def test_iface(self):
     180        # make sure we fullfill interface contracts
     181        obj = DefaultObjectConverter(IContact)
     182        verify.verifyObject(IObjectConverter, obj)
     183        verify.verifyClass(IObjectConverter, DefaultObjectConverter)
    155184        return
    156185
Note: See TracChangeset for help on using the changeset viewer.