Commit 6affc128 authored by Łukasz Nowak's avatar Łukasz Nowak

- as everything is tested *exactly* same way use automagically generated test...

 - as everything is tested *exactly* same way use automagically generated test and list of tuples to define implementations


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27391 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7b336f5
...@@ -30,88 +30,49 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -30,88 +30,49 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
import unittest import unittest
# this list can be generated automatically using introspection or can be set
# manually and treated as reference to what implements what
implements_tuple_list = [
('TradeModelCell', 'ITransformation'),
('TradeModelCell', 'IVariated'),
('TradeModelLine', 'ITransformation'),
('TradeModelLine', 'IVariated'),
('Transformation', 'ITransformation'),
('Transformation', 'IVariated'),
('BusinessPath', 'IBusinessPath'),
('BusinessPath', 'IArrow'),
('BusinessPath', 'ICategoryAccessProvider'),
('TradeModelRule', 'IRule'),
('TradeModelRule', 'IPredicate'),
('TransformationRule', 'IRule'),
('TransformationRule', 'IPredicate'),
('TransformedResource', 'IVariated'),
]
class TestERP5Interfaces(ERP5TypeTestCase): class TestERP5Interfaces(ERP5TypeTestCase):
"""Test that every class implements interfaces properly""" """Test that every class implements interfaces properly"""
# TODO: Do it automagic way, maybe introspection: def makeTestMethod(document, interface):
# Like in testXHTMLStyle add test methods def testMethod(self):
# for interface in interface_list: _temp = __import__('Products.ERP5Type.Document.%s' % document, globals(),
# for class in class_list: locals(), ['%s' % document])
# if interface.implementedBy(class): Document = getattr(_temp, document)
# self.createInterfaceTest(interface, class) _temp = __import__('Products.ERP5Type.interfaces', globals(), locals(),
# ['%s' % interface])
# and then nice result of declared interfaces Interface = getattr(_temp, interface)
def test_TradeModelCell_implements_ITransformation(self):
from Products.ERP5Type.Document.TradeModelCell import TradeModelCell
from Products.ERP5Type.interfaces import ITransformation
verifyClass(ITransformation, TradeModelCell)
def test_TradeModelCell_implements_IVariated(self):
from Products.ERP5Type.Document.TradeModelCell import TradeModelCell
from Products.ERP5Type.interfaces import IVariated
verifyClass(IVariated, TradeModelCell)
def test_TradeModelLine_implements_ITransformation(self):
from Products.ERP5Type.Document.TradeModelLine import TradeModelLine
from Products.ERP5Type.interfaces import ITransformation
verifyClass(ITransformation, TradeModelLine)
def test_TradeModelLine_implements_IVariated(self):
from Products.ERP5Type.Document.TradeModelLine import TradeModelLine
from Products.ERP5Type.interfaces import IVariated
verifyClass(IVariated, TradeModelLine)
def test_Transformation_implements_ITransformation(self):
from Products.ERP5Type.Document.Transformation import Transformation
from Products.ERP5Type.interfaces import ITransformation
verifyClass(ITransformation, Transformation)
def test_Transformation_implements_IVariated(self):
from Products.ERP5Type.Document.Transformation import Transformation
from Products.ERP5Type.interfaces import IVariated
verifyClass(IVariated, Transformation)
def test_BusinessPath_implements_IBusinessPath(self):
from Products.ERP5Type.Document.BusinessPath import BusinessPath
from Products.ERP5Type.interfaces import IBusinessPath
verifyClass(IBusinessPath, BusinessPath)
def test_BusinessPath_implements_IArrow(self):
from Products.ERP5Type.Document.BusinessPath import BusinessPath
from Products.ERP5Type.interfaces import IArrow
verifyClass(IArrow, BusinessPath)
def test_BusinessPath_implements_ICategoryAccessProvider(self):
from Products.ERP5Type.Document.BusinessPath import BusinessPath
from Products.ERP5Type.interfaces import ICategoryAccessProvider
verifyClass(ICategoryAccessProvider, BusinessPath)
def test_TradeModelRule_implements_IRule(self): verifyClass(Interface, Document)
from Products.ERP5Type.Document.TradeModelRule import TradeModelRule
from Products.ERP5Type.interfaces import IRule
verifyClass(IRule, TradeModelRule)
def test_TradeModelRule_implements_IPredicate(self): return testMethod
from Products.ERP5Type.Document.TradeModelRule import TradeModelRule
from Products.ERP5Type.interfaces import IPredicate
verifyClass(IPredicate, TradeModelRule)
def test_TransformationRule_implements_IRule(self): def addTestMethodDynamically():
from Products.ERP5Type.Document.TransformationRule import TransformationRule for document, interface in implements_tuple_list:
from Products.ERP5Type.interfaces import IRule method_name = 'test_%s_implements_%s' % (document, interface)
verifyClass(IRule, TransformationRule) method = makeTestMethod(document, interface)
setattr(TestERP5Interfaces, method_name, method)
def test_TransformationRule_implements_IPredicate(self):
from Products.ERP5Type.Document.TransformationRule import TransformationRule
from Products.ERP5Type.interfaces import IPredicate
verifyClass(IPredicate, TransformationRule)
def test_TransformedResource_implements_IVariated(self): addTestMethodDynamically()
from Products.ERP5Type.Document.TransformedResource import TransformedResource
from Products.ERP5Type.interfaces import IVariated
verifyClass(IVariated, TransformedResource)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment