Ejemplo n.º 1
0
class TestTypeVariants(unittest.TestCase):
    """ test typeVariant attribute of factory to load different objects given
    the same tag. (special attrib values are given that differentiate them)
    """
    def setUp(self):
        self.variants = [mme.Hook,  # I removed richcontent variants because
# they do not work correctly when their html is not set. it causes ET to crash
                mme.EmbeddedImage, mme.MapConfig, mme.Equation,
                mme.AutomaticEdgeColor]
        self.mm = MindMap()
        root = self.mm[0]
        root[:] = []  # clear out children of root
        for variant in self.variants:
            root.append(variant())  # add a child variant element type
        self.filename = uuid4().hex + '.mm'
        self.mm.write(self.filename)  # need to remember to erase file later...
        self.mm2 = pymm.read(self.filename)

    def test_for_variants(self):
        """ check that each of the variants is a child in root node """
        root = self.mm2[0]
        variants = self.variants.copy()
        for variant in variants:
            for child in root[:]:
                if isinstance(child, variant):
                    break
            else:  # we only reach else: if no child matched the given variant
                self.fail('no child of type: ' + str(variant)) 
            root.remove(child)  # remove child after it matches a variant
Ejemplo n.º 2
0
    def setUp(self):
        self.variants = [mme.Hook,  # I removed richcontent variants because
# they do not work correctly when their html is not set. it causes ET to crash
                mme.EmbeddedImage, mme.MapConfig, mme.Equation,
                mme.AutomaticEdgeColor]
        self.mm = MindMap()
        root = self.mm[0]
        root[:] = []  # clear out children of root
        for variant in self.variants:
            root.append(variant())  # add a child variant element type
        self.filename = uuid4().hex + '.mm'
        self.mm.write(self.filename)  # need to remember to erase file later...
        self.mm2 = pymm.read(self.filename)
Ejemplo n.º 3
0
Archivo: tests.py Proyecto: maqwqa/pymm
 def test_write_file(self):
     mm = MindMap()
     mm.writefile('test_write.mm')
Ejemplo n.º 4
0
 def test_write_file(self):
     mm = MindMap()
     mm.write('write_test.mm')  # just test that no errors are thrown
Ejemplo n.º 5
0
Archivo: tests.py Proyecto: maqwqa/pymm
 def test_read_file(self):
     mm = MindMap()
     mm.readfile('../docs/input.mm')
     self.assertTrue(mm)
     self.assertTrue(mm.getroot())
     mm.writefile('input_2.mm')