#!/usr/bin/env python
import coral

prj = coral.Project()
prj.setFilename("example_link_filename.xml")

L = coral.lang.CoralEx10
d = L.InternalQtDragAndDrop.DragAndDrop()

assert L.InternalQtDragAndDrop.__package__() == L
assert L.InternalQtDragAndDrop.getXMLNS() != ""

a1 = coral.lang.UML14.Class()
a2 = coral.lang.UML14.Package()
a1.__setProject__(prj)
a2.__setProject__(prj)

d.linkedContents.append(a1)
d.linkedContents.append(a2)

o = coral.Set()
o.add(d)
print coral.saveDocument_str(o, "2.0")

prj2 = coral.Project()
prj2.setFilename("tmp/testMOFPackages.xml")
d.__setProject__(prj2)
coral.saveDocument(prj2)

prj2.invalidate()

prj2 = coral.loadDocument("tmp/testMOFPackages.xml")
assert prj2
assert len(prj2.contents()) == 1
assert prj2.contents()[0].__type__() == L.InternalQtDragAndDrop.DragAndDrop

