#!/usr/bin/env python

import coral
import coral.util.search.query as Q

prj=coral.loadDocument("testIsKindOf.xml")

target=None
query=None

for elem in prj.contents():
    if elem.oclIsKindOf(coral.lang.UML14.Model):
        if elem.name=="Target":
            target=elem
        if elem.name=="Query":
            query=elem

assert target
assert query

matches=Q.search_isKindOf(query.ownedElement, target)
assert len(matches) == 2

class X:
    pass

try:
    Q.search_isKindOf(query.ownedElement, target,None,False,X)
except:
    pass
else:
    assert 0
