#!/usr/bin/env python
import coral as coral

storage = coral.loadDocument("multiple_roots.xmi")
assert storage
roots = storage.contents()
assert roots
assert roots.size() == 3

for i in roots:
    i.__getProject__() == storage

assert roots[0].name == "MyModel1"
assert roots[1].name == "MyModel2"
assert roots[2].name == "MyModel3"

storage.setFilename("tmp/multiple_roots2.xmi")
coral.saveDocument(storage)

import os
os.rename("tmp/multiple_roots2.xmi", "tmp/multiple_roots3.xmi")

newST = coral.loadDocument("tmp/multiple_roots3.xmi")
assert newST
roots = newST.contents()
assert roots
assert roots.size() == 3

for i in roots:
    i.__getProject__() == newST

assert roots[0].name == "MyModel1"
assert roots[1].name == "MyModel2"
assert roots[2].name == "MyModel3"
