Back to index

enigmail  1.4.3
Public Member Functions
runtests.TestTypelibMerge Class Reference

List of all members.

Public Member Functions

def test_mergeDifferent
def test_mergeConflict
def test_mergeUnresolvedIID
def test_mergeResolvedUnresolved
def test_mergeReplaceParents
def test_mergeReplaceRetval
def test_mergeReplaceParams
def test_mergeReplaceArrayTypeParams

Detailed Description

Definition at line 365 of file runtests.py.


Member Function Documentation

Test that merging two typelibs with conflicting interface definitions
raises an error.

Definition at line 399 of file runtests.py.

00399 
00400     def test_mergeConflict(self):
00401         """
00402         Test that merging two typelibs with conflicting interface definitions
00403         raises an error.
00404         
00405         """
00406         # Same names, different IIDs
00407         t1 = xpt.Typelib()
00408         # add an unresolved interface
00409         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
00410         t2 = xpt.Typelib()
00411         # add an unresolved interface, same name different IID
00412         t2.interfaces.append(xpt.Interface("IFoo", iid="44332211-6655-8877-0099-aabbccddeeff"))
00413         self.assertRaises(xpt.DataError, t1.merge, t2)
00414 
00415         # Same IIDs, different names
00416         t1 = xpt.Typelib()
00417         # add an unresolved interface
00418         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
00419         t2 = xpt.Typelib()
00420         # add an unresolved interface, same IID different name
00421         t2.interfaces.append(xpt.Interface("IBar", iid="11223344-5566-7788-9900-aabbccddeeff"))
00422         self.assertRaises(xpt.DataError, t1.merge, t2)

Test that merging two typelibs with completely different interfaces
produces the correctly merged typelib.

Definition at line 366 of file runtests.py.

00366 
00367     def test_mergeDifferent(self):
00368         """
00369         Test that merging two typelibs with completely different interfaces
00370         produces the correctly merged typelib.
00371         
00372         """
00373         t1 = xpt.Typelib()
00374         # add an unresolved interface
00375         t1.interfaces.append(xpt.Interface("IFoo"))
00376         t2 = xpt.Typelib()
00377         # add an unresolved interface
00378         t2.interfaces.append(xpt.Interface("IBar"))
00379         t1.merge(t2)
00380         
00381         self.assertEqual(2, len(t1.interfaces))
00382         # Interfaces should wind up sorted
00383         self.assertEqual("IBar", t1.interfaces[0].name)
00384         self.assertEqual("IFoo", t1.interfaces[1].name)
00385 
00386         # Add some IID values
00387         t1 = xpt.Typelib()
00388         # add an unresolved interface
00389         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
00390         t2 = xpt.Typelib()
00391         # add an unresolved interface
00392         t2.interfaces.append(xpt.Interface("IBar", iid="44332211-6655-8877-0099-aabbccddeeff"))
00393         t1.merge(t2)
00394         
00395         self.assertEqual(2, len(t1.interfaces))
00396         # Interfaces should wind up sorted
00397         self.assertEqual("IFoo", t1.interfaces[0].name)
00398         self.assertEqual("IBar", t1.interfaces[1].name)

Here is the call graph for this function:

Test that merging an interface correctly updates ArrayType
params whose element_type is an InterfaceType on methods
of other interfaces.

Definition at line 708 of file runtests.py.

00708 
00709     def test_mergeReplaceArrayTypeParams(self):
00710         """
00711         Test that merging an interface correctly updates ArrayType
00712         params whose element_type is an InterfaceType on methods
00713         of other interfaces.
00714 
00715         """
00716         # t1 has an unresolved interface and an interface that uses the
00717         # unresolved interface as a type in an ArrayType in a parameter
00718         # of a method. t2 has a resolved version of the unresolved interface.
00719         t1 = xpt.Typelib()
00720         # add an unresolved interface
00721         i = xpt.Interface("IFoo")
00722         t1.interfaces.append(i)
00723         # add an interface that uses the unresolved interface
00724         # as a type in an ArrayType in a param value in a method.
00725         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00726         intp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32))
00727         p = xpt.Param(xpt.ArrayType(xpt.InterfaceType(i), 1, 2))
00728         m = xpt.Method("ArrayIfaceParam", vp, params=[p, intp, intp])
00729         t1.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
00730                                            methods=[m]))
00731         t2 = xpt.Typelib()
00732         # add a resolved interface
00733         m = xpt.Method("Bar", vp)
00734         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00735                                            methods=[m]))
00736         t1.merge(t2)
00737         
00738         self.assertEqual(2, len(t1.interfaces))
00739         self.assertEqual("IParam", t1.interfaces[0].name)
00740         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00741         self.assertEqual("IFoo", t1.interfaces[1].name)
00742         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00743         self.assert_(t1.interfaces[1].resolved)
00744         # Ensure that IRetval's method's param type has been updated.
00745         self.assertEqual(1, len(t1.interfaces[0].methods))
00746         self.assert_(t1.interfaces[0].methods[0].params[0].type.element_type.iface.resolved)
00747         self.assertEqual(t1.interfaces[1],
00748                          t1.interfaces[0].methods[0].params[0].type.element_type.iface)

Here is the call graph for this function:

Test that merging an interface correctly updates InterfaceType
params on methods of other interfaces.

Definition at line 635 of file runtests.py.

00635 
00636     def test_mergeReplaceParams(self):
00637         """
00638         Test that merging an interface correctly updates InterfaceType
00639         params on methods of other interfaces.
00640 
00641         """
00642         # t1 has an unresolved interface and an interface that uses the
00643         # unresolved interface as a param value in a method. t2
00644         # has a resolved version of the unresolved interface.
00645         t1 = xpt.Typelib()
00646         # add an unresolved interface
00647         i = xpt.Interface("IFoo")
00648         t1.interfaces.append(i)
00649         # add an interface that uses the unresolved interface
00650         # as a param value in a method.
00651         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00652         p = xpt.Param(xpt.InterfaceType(i))
00653         m = xpt.Method("IfaceParam", vp, params=[p])
00654         t1.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
00655                                            methods=[m]))
00656         t2 = xpt.Typelib()
00657         # add a resolved interface
00658         m = xpt.Method("Bar", vp)
00659         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00660                                            methods=[m]))
00661         t1.merge(t2)
00662         
00663         self.assertEqual(2, len(t1.interfaces))
00664         self.assertEqual("IParam", t1.interfaces[0].name)
00665         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00666         self.assertEqual("IFoo", t1.interfaces[1].name)
00667         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00668         self.assert_(t1.interfaces[1].resolved)
00669         # Ensure that IRetval's method's param type has been updated.
00670         self.assertEqual(1, len(t1.interfaces[0].methods))
00671         self.assert_(t1.interfaces[0].methods[0].params[0].type.iface.resolved)
00672         self.assertEqual(t1.interfaces[1],
00673                          t1.interfaces[0].methods[0].params[0].type.iface)
00674 
00675         # t1 has a resolved interface. t2 has an unresolved version
00676         # and an interface that uses the unresolved interface as a
00677         # param value in a method.
00678         t1 = xpt.Typelib()
00679         # add a resolved interface
00680         m = xpt.Method("Bar", vp)
00681         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00682                                            methods=[m]))
00683         t2 = xpt.Typelib()
00684         # add an unresolved interface
00685         i = xpt.Interface("IFoo")
00686         t2.interfaces.append(i)
00687         # add an interface that uses the unresolved interface
00688         # as a param value in a method.
00689         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00690         p = xpt.Param(xpt.InterfaceType(i))
00691         m = xpt.Method("IfaceParam", vp, params=[p])
00692         t2.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
00693                                            methods=[m]))
00694         t1.merge(t2)
00695         
00696         self.assertEqual(2, len(t1.interfaces))
00697         self.assertEqual("IParam", t1.interfaces[0].name)
00698         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00699         self.assertEqual("IFoo", t1.interfaces[1].name)
00700         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00701         self.assert_(t1.interfaces[1].resolved)
00702         # Ensure that IRetval's method's param type has been updated.
00703         self.assertEqual(1, len(t1.interfaces[0].methods))
00704         self.assert_(t1.interfaces[0].methods[0].params[0].type.iface.resolved)
00705         self.assertEqual(t1.interfaces[1],
00706                          t1.interfaces[0].methods[0].params[0].type.iface)
00707 

Here is the call graph for this function:

Test that merging an interface results in other interfaces' parent
member being updated properly.

Definition at line 501 of file runtests.py.

00501 
00502     def test_mergeReplaceParents(self):
00503         """
00504         Test that merging an interface results in other interfaces' parent
00505         member being updated properly.
00506 
00507         """
00508         # t1 has an unresolved interface, t2 has a resolved version,
00509         # but t1 also has another interface whose parent is the unresolved
00510         # interface.
00511         t1 = xpt.Typelib()
00512         # add an unresolved interface
00513         pi = xpt.Interface("IFoo")
00514         t1.interfaces.append(pi)
00515         # add a child of the unresolved interface
00516         t1.interfaces.append(xpt.Interface("IChild", iid="11111111-1111-1111-1111-111111111111",
00517                                            resolved=True, parent=pi))
00518         t2 = xpt.Typelib()
00519         # add a resolved interface
00520         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00521         m = xpt.Method("Bar", p)
00522         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00523                                            methods=[m]))
00524         t1.merge(t2)
00525         
00526         self.assertEqual(2, len(t1.interfaces))
00527         self.assertEqual("IChild", t1.interfaces[0].name)
00528         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00529         self.assertEqual("IFoo", t1.interfaces[1].name)
00530         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00531         self.assert_(t1.interfaces[0].resolved)
00532         # Ensure that IChild's parent has been updated
00533         self.assertEqual(t1.interfaces[1], t1.interfaces[0].parent)
00534         self.assert_(t1.interfaces[0].parent.resolved)
00535 
00536         # t1 has a resolved interface, t2 has an unresolved version,
00537         # but t2 also has another interface whose parent is the unresolved
00538         # interface.
00539         t1 = xpt.Typelib()
00540         # add a resolved interface
00541         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00542         m = xpt.Method("Bar", p)
00543         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00544                                            methods=[m]))
00545         t2 = xpt.Typelib()
00546         # add an unresolved interface
00547         pi = xpt.Interface("IFoo")
00548         t2.interfaces.append(pi)
00549         # add a child of the unresolved interface
00550         t2.interfaces.append(xpt.Interface("IChild", iid="11111111-1111-1111-1111-111111111111",
00551                                            resolved=True, parent=pi))
00552         t1.merge(t2)
00553         
00554         self.assertEqual(2, len(t1.interfaces))
00555         self.assertEqual("IChild", t1.interfaces[0].name)
00556         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00557         self.assertEqual("IFoo", t1.interfaces[1].name)
00558         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00559         self.assert_(t1.interfaces[0].resolved)
00560         # Ensure that IChild's parent has been updated
00561         self.assertEqual(t1.interfaces[1], t1.interfaces[0].parent)
00562         self.assert_(t1.interfaces[0].parent.resolved)

Here is the call graph for this function:

Test that merging an interface correctly updates InterfaceType
return values on methods of other interfaces.

Definition at line 563 of file runtests.py.

00563 
00564     def test_mergeReplaceRetval(self):
00565         """
00566         Test that merging an interface correctly updates InterfaceType
00567         return values on methods of other interfaces.
00568 
00569         """
00570         # t1 has an unresolved interface and an interface that uses the
00571         # unresolved interface as a return value from a method. t2
00572         # has a resolved version of the unresolved interface.
00573         t1 = xpt.Typelib()
00574         # add an unresolved interface
00575         i = xpt.Interface("IFoo")
00576         t1.interfaces.append(i)
00577         # add an interface that uses the unresolved interface
00578         # as a return value in a method.
00579         p = xpt.Param(xpt.InterfaceType(i))
00580         m = xpt.Method("ReturnIface", p)
00581         t1.interfaces.append(xpt.Interface("IRetval", iid="11111111-1111-1111-1111-111111111111",
00582                                            methods=[m]))
00583         t2 = xpt.Typelib()
00584         # add a resolved interface
00585         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00586         m = xpt.Method("Bar", p)
00587         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00588                                            methods=[m]))
00589         t1.merge(t2)
00590         
00591         self.assertEqual(2, len(t1.interfaces))
00592         self.assertEqual("IRetval", t1.interfaces[0].name)
00593         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00594         self.assertEqual("IFoo", t1.interfaces[1].name)
00595         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00596         self.assert_(t1.interfaces[1].resolved)
00597         # Ensure that IRetval's method's return value type has been updated.
00598         self.assertEqual(1, len(t1.interfaces[0].methods))
00599         self.assert_(t1.interfaces[0].methods[0].result.type.iface.resolved)
00600         self.assertEqual(t1.interfaces[1],
00601                          t1.interfaces[0].methods[0].result.type.iface)
00602 
00603         # t1 has a resolved interface. t2 has an unresolved version and
00604         # an interface that uses the unresolved interface as a return value
00605         # from a method.
00606         t1 = xpt.Typelib()
00607         # add a resolved interface
00608         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00609         m = xpt.Method("Bar", p)
00610         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00611                                            methods=[m]))
00612         t2 = xpt.Typelib()
00613         # add an unresolved interface
00614         i = xpt.Interface("IFoo")
00615         t2.interfaces.append(i)
00616         # add an interface that uses the unresolved interface
00617         # as a return value in a method.
00618         p = xpt.Param(xpt.InterfaceType(i))
00619         m = xpt.Method("ReturnIface", p)
00620         t2.interfaces.append(xpt.Interface("IRetval", iid="11111111-1111-1111-1111-111111111111",
00621                                            methods=[m]))
00622         t1.merge(t2)
00623         
00624         self.assertEqual(2, len(t1.interfaces))
00625         self.assertEqual("IRetval", t1.interfaces[0].name)
00626         self.assertEqual("11111111-1111-1111-1111-111111111111", t1.interfaces[0].iid)
00627         self.assertEqual("IFoo", t1.interfaces[1].name)
00628         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[1].iid)
00629         self.assert_(t1.interfaces[1].resolved)
00630         # Ensure that IRetval's method's return value type has been updated.
00631         self.assertEqual(1, len(t1.interfaces[0].methods))
00632         self.assert_(t1.interfaces[0].methods[0].result.type.iface.resolved)
00633         self.assertEqual(t1.interfaces[1],
00634                          t1.interfaces[0].methods[0].result.type.iface)

Here is the call graph for this function:

Test that merging two typelibs, one of which contains an unresolved
reference to an interface, and the other of which contains a
resolved reference to the same interface results in keeping the
resolved reference.

Definition at line 455 of file runtests.py.

00455 
00456     def test_mergeResolvedUnresolved(self):
00457         """
00458         Test that merging two typelibs, one of which contains an unresolved
00459         reference to an interface, and the other of which contains a
00460         resolved reference to the same interface results in keeping the
00461         resolved reference.
00462 
00463         """
00464         # t1 has an unresolved interface, t2 has a resolved version
00465         t1 = xpt.Typelib()
00466         # add an unresolved interface
00467         t1.interfaces.append(xpt.Interface("IFoo"))
00468         t2 = xpt.Typelib()
00469         # add a resolved interface
00470         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00471         m = xpt.Method("Bar", p)
00472         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00473                                            methods=[m]))
00474         t1.merge(t2)
00475         
00476         self.assertEqual(1, len(t1.interfaces))
00477         self.assertEqual("IFoo", t1.interfaces[0].name)
00478         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[0].iid)
00479         self.assert_(t1.interfaces[0].resolved)
00480         self.assertEqual(1, len(t1.interfaces[0].methods))
00481         self.assertEqual("Bar", t1.interfaces[0].methods[0].name)
00482 
00483         # t1 has a resolved interface, t2 has an unresolved version
00484         t1 = xpt.Typelib()
00485         # add a resolved interface
00486         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
00487         m = xpt.Method("Bar", p)
00488         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
00489                                            methods=[m]))
00490         t2 = xpt.Typelib()
00491         # add an unresolved interface
00492         t2.interfaces.append(xpt.Interface("IFoo"))
00493         t1.merge(t2)
00494         
00495         self.assertEqual(1, len(t1.interfaces))
00496         self.assertEqual("IFoo", t1.interfaces[0].name)
00497         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[0].iid)
00498         self.assert_(t1.interfaces[0].resolved)
00499         self.assertEqual(1, len(t1.interfaces[0].methods))
00500         self.assertEqual("Bar", t1.interfaces[0].methods[0].name)

Here is the call graph for this function:

Test that merging a typelib with an unresolved definition of
an interface that's also unresolved in this typelib, but one
has a valid IID copies the IID value to the resulting typelib.

Definition at line 423 of file runtests.py.

00423 
00424     def test_mergeUnresolvedIID(self):
00425         """
00426         Test that merging a typelib with an unresolved definition of
00427         an interface that's also unresolved in this typelib, but one
00428         has a valid IID copies the IID value to the resulting typelib.
00429 
00430         """
00431         # Unresolved in both, but t1 has an IID value
00432         t1 = xpt.Typelib()
00433         # add an unresolved interface with a valid IID
00434         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
00435         t2 = xpt.Typelib()
00436         # add an unresolved interface, no IID
00437         t2.interfaces.append(xpt.Interface("IFoo"))
00438         t1.merge(t2)
00439         
00440         self.assertEqual(1, len(t1.interfaces))
00441         self.assertEqual("IFoo", t1.interfaces[0].name)
00442         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[0].iid)
00443         # Unresolved in both, but t2 has an IID value
00444         t1 = xpt.Typelib()
00445         # add an unresolved interface, no IID
00446         t1.interfaces.append(xpt.Interface("IFoo"))
00447         t2 = xpt.Typelib()
00448         # add an unresolved interface with a valid IID
00449         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
00450         t1.merge(t2)
00451         
00452         self.assertEqual(1, len(t1.interfaces))
00453         self.assertEqual("IFoo", t1.interfaces[0].name)
00454         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t1.interfaces[0].iid)

Here is the call graph for this function:


The documentation for this class was generated from the following file: