#!/usr/bin/env python
import os
from coral.modeler import modeler,action
import coral

UML14 = coral.lang.UML14

m=modeler.ModelerWindow()

storage=m.openProject("actionTest.xmi")
m.main(loop=0)

# check that we have all 3 searchlets
allLabels=action.searchGetLabelList()
assert "Name" in allLabels
assert "Type Name" in allLabels
assert "Expression" in allLabels

# Find the class named "Class_1"
action.searchStart("Name","Class_1")
while action.searchIsActive():
    m.processEvents()
    
    
res=action.searchGetResults()

assert len(res)==1

print "res[0].name",res[0].name
assert res[0].name=="Class_1"
assert res[0].oclIsKindOf(UML14.Class)


action.searchStart("Type Name","Model")
while action.searchIsActive():
    m.processEvents()


res=action.searchGetResults()

assert len(res)==1
assert res[0].oclIsKindOf(UML14.Model)

