예제 #1
0
 def test_example1(self):
     doc = imscp.ManifestDocument()
     doc.read(src=io.BytesIO(EXAMPLE_1))
     root = doc.root
     self.assertTrue(isinstance(root, imscp.Manifest))
     self.assertTrue(root.ns == imscp.IMSCP_NAMESPACE and
                     root.xmlname == 'manifest')
     self.assertTrue(root.id == 'test')
예제 #2
0
 def test_delete_file(self):
     doc = imscp.ManifestDocument()
     doc.read(src=io.BytesIO(EXAMPLE_2))
     r = doc.get_element_by_id('choice')
     index = len(r.File)
     f = r.File[0]
     f1 = r.File[1]
     r.DeleteFile(f)
     self.assertTrue(len(r.File) == index - 1 and r.File[0] is f1)
예제 #3
0
 def test_new_file(self):
     doc = imscp.ManifestDocument()
     doc.read(src=io.BytesIO(EXAMPLE_2))
     r = doc.get_element_by_id('choice')
     index = len(r.File)
     f = r.add_child(r.FileClass)
     f.set_attribute('href', 'Extra.txt')
     self.assertTrue(isinstance(f, imscp.File))
     self.assertTrue(len(r.File) == index + 1 and r.File[index] is f)
예제 #4
0
 def test_set_i_d(self):
     doc = imscp.ManifestDocument()
     doc.read(src=io.BytesIO(EXAMPLE_1))
     manifest = doc.get_element_by_id("test")
     self.assertTrue(doc.root is manifest)
     manifest.set_id("manifest")
     self.assertTrue(doc.get_element_by_id("test") is None,
                     "Old identifier still declared")
     self.assertTrue(doc.get_element_by_id("manifest") is manifest,
                     "New identifier not declared")
예제 #5
0
 def test_example2(self):
     doc = imscp.ManifestDocument()
     doc.read(src=io.BytesIO(EXAMPLE_2))
     resources = doc.root.Resources
     self.assertTrue(len(resources.Resource) == 1 and
                     isinstance(resources.Resource[0], imscp.Resource))
     manifest = doc.get_element_by_id("MANIFEST-QTI-1")
     self.assertTrue(doc.root is manifest and
                     isinstance(manifest, imscp.Manifest))
     resource = doc.get_element_by_id("choice")
     self.assertTrue(resource is resources.Resource[0])
예제 #6
0
 def test_new_resource(self):
     doc = imscp.ManifestDocument(root=imscp.Manifest)
     resources = doc.root.Resources
     try:
         resource = resources.add_child(resources.ResourceClass)
         resource.set_id('resource#1')
         resource.type = 'imsqti_item_xmlv2p1'
         self.fail("Invalid Name for resource identifier")
     except xml.XMLIDValueError:
         pass
     resource.set_id('resource_1')
     resource.type = 'imsqti_item_xmlv2p1'
     self.assertTrue(isinstance(resource, imscp.Resource))
     self.assertTrue(doc.get_element_by_id('resource_1') is resource)
     self.assertTrue(len(resources.Resource) == 1 and
                     resources.Resource[0] is resource)
예제 #7
0
 def testCaseExample1(self):
     doc = imscp.ManifestDocument()
     doc.read(src=StringIO(EXAMPLE_1))
     r = doc.get_element_by_id('choice')
     self.assertTrue(isinstance(list(r.Metadata.get_children())[0], LOM),
                     "LOM")
예제 #8
0
 def test_constructor(self):
     doc = imscp.ManifestDocument()
     self.assertTrue(isinstance(doc, xmlns.XMLNSDocument))
     doc = imscp.ManifestDocument(root=imscp.Manifest)
     root = doc.root
     self.assertTrue(isinstance(root, imscp.Manifest))
예제 #9
0
 def testCaseExample1(self):
     doc = imscp.ManifestDocument()
     doc.Read(src=StringIO(EXAMPLE_1))
     r = doc.GetElementByID('choice')
     self.assertTrue(isinstance(list(r.Metadata.GetChildren())[0], LOM),
                     "LOM")