#!/usr/bin/env python
import coral
L = coral.lang.UML14

m1=L.Model(name="M1")
m2=L.Model(name="M2")
p=L.Package(name="P")
m1.ownedElement.append(p)
assert (p.namespace==m1)
assert (p in m1.ownedElement)
m2.ownedElement.append(p)
assert (p.namespace==m2)
assert (p in m2.ownedElement)
assert (p not in m1.ownedElement)

p.namespace=m1
assert (p in m1.ownedElement)
p.namespace=m2
assert (p in m2.ownedElement)
assert (p not in m1.ownedElement)

assert(p.__isPart__(m2))
print ">>", m1,m2,p
assert(not p.__isPart__(m1))
print "<<"
c=L.Class()
p.ownedElement.insert(c)
assert(c.__isPart__(m2))

d=L.Dependency()

d.supplier.insert(m1)
d.client.insert(m2)
assert(d in m1.supplierDependency)
assert(d in m2.clientDependency)
assert(m1 in d.supplier)
assert(m2 in d.client)

d.supplier=[]
assert(not d in m1.supplierDependency)
assert(not m1 in d.supplier)

