#!/usr/bin/env python
from coral.modeler.extension import *
from coral.modeler.unittests.anExtension import *

print "<1>"
e=ExtensionRegistry()

print "<2>"
e.register("DiagramElementExt","Namespace","coral.modeler.unittests.anExtension.LowPriority",1,1)
e.register("DiagramEditorToolbarEntry","Namespace","coral.modeler.unittests.anExtension.HighPriority",3,1)

import coral
metamodel=coral.lang.UML14 

c=metamodel.Package()

print "<3>"
cl=e.getRegisteredExtensionsByType("DiagramEditorToolbarEntry")

print cl

assert ["Namespace",HighPriority] in cl
assert not ["Namespace",LowPriority] in cl



e.register("DiagramEditorToolbarEntry","Namespace","coral.modeler.unittests.anExtension.HighestPriority",5,1)

cl=e.getRegisteredExtensionsByType("DiagramEditorToolbarEntry")
assert ["Namespace",HighestPriority] in cl # Make sure that the extension with highest priority overrides the other extensions with the same order
assert not ["Namespace",LowPriority] in cl


cl=e.getRegisteredExtensionsByType("DiagramElementExt")
print cl
assert not ["Namespace",HighPriority] in cl


#e.addManifest("emanifest.txt")
