[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ComponentArchitecture/tests - testInterfaceField.py:1.2

Jim Fulton jim@zope.com
Wed, 4 Dec 2002 04:54:07 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv13028/tests

Added Files:
	testInterfaceField.py 
Log Message:
Added interface fields and widgets for keeping track of interfaces
(e.g. for adapter configurations).


=== Zope3/lib/python/Zope/App/ComponentArchitecture/tests/testInterfaceField.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec  4 04:54:07 2002
+++ Zope3/lib/python/Zope/App/ComponentArchitecture/tests/testInterfaceField.py	Wed Dec  4 04:54:06 2002
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""Interface fields tests
+
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+import Interface
+from Zope.App.ComponentArchitecture.InterfaceField import InterfaceField
+from Zope.Schema.Exceptions import ValidationError
+        
+class Test(TestCase):
+
+    def test_validate(self):
+        field = InterfaceField()
+        
+        field.validate(Interface.Interface)
+        class I(Interface.Interface): pass
+        field.validate(I)
+        
+        self.assertRaises(ValidationError, field.validate, Interface)
+        class I: pass
+        self.assertRaises(ValidationError, field.validate, I)
+
+def test_suite():
+    return TestSuite((makeSuite(Test),))
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')
+