def test_fromZ2Interface_methods(self): from Products.Five.bridge import fromZ2Interface class IMethods(Z2_Interface): def one(): """One method.""" def another(arg1, arg2): """Another method, taking arguments.""" converted = fromZ2Interface(IMethods) self.failUnless(Z3_Interface.isEqualOrExtendedBy(converted)) self.assertEqual(len(converted.names()), 2) self.failUnless('one' in converted.names()) self.failUnless('another' in converted.names()) one = converted.getDescriptionFor('one') self.failUnless(isinstance(one, Z3_Method)) self.assertEqual(one.getName(), 'one') self.assertEqual(one.getDoc(), 'One method.') another = converted.getDescriptionFor('another') self.failUnless(isinstance(another, Z3_Method)) self.assertEqual(another.getName(), 'another') self.assertEqual(another.getDoc(), 'Another method, taking arguments.')
def test_fromZ2Interface_empty(self): from Products.Five.bridge import fromZ2Interface class IEmpty(Z2_Interface): pass converted = fromZ2Interface(IEmpty) self.failUnless(Z3_Interface.isEqualOrExtendedBy(converted)) self.assertEqual(len(converted.names()), 0)
def test_fromZ2Interface_attributes(self): from Products.Five.bridge import fromZ2Interface class IAttributes(Z2_Interface): one = Z2_Attribute('one', 'One attribute') another = Z2_Attribute('another', 'Another attribute') converted = fromZ2Interface(IAttributes) self.failUnless(Z3_Interface.isEqualOrExtendedBy(converted)) self.assertEqual(len(converted.names()), 2) self.failUnless('one' in converted.names()) self.failUnless('another' in converted.names()) one = converted.getDescriptionFor('one') self.failUnless(isinstance(one, Z3_Attribute)) self.assertEqual(one.getName(), 'one') self.assertEqual(one.getDoc(), 'One attribute') another = converted.getDescriptionFor('another') self.failUnless(isinstance(another, Z3_Attribute)) self.assertEqual(another.getName(), 'another') self.assertEqual(another.getDoc(), 'Another attribute')