Ejemplo n.º 1
0
 def export_python(cls):
     from mosaicode.system import System
     System()
     blocks = System.get_blocks()
     for block in blocks:
         print "Exporting block " + block
         BlockPersistence.save_python(blocks[block])
Ejemplo n.º 2
0
class TestBlockPersistence(TestCase):
    def setUp(self):
        """Do the test basic setup."""
        self.blockpersistence = BlockPersistence()

    # ----------------------------------------------------------------------x
    def test_load(self):

        # TESTANDO COM NOME DE ARQUIVO = None
        file_name = ""
        self.assertIsNone(self.blockpersistence.load(file_name))

        # TESTANDO COM NOME DE ARQUIVO INEXISTENTE
        file_name = "/home/lucas/mosaicode/extensions/teste.py"
        self.assertIsNone(self.blockpersistence.load(file_name))

        # TESTANDO COM NOME DE ARQUIVO FALSO (INCOMPATÍVEL)
        file_name = "/home/lucas/mosaicode/extensions/a.py"
        self.assertIsNone(self.blockpersistence.load(file_name))

        # TESTANDO COM NOME DE ARQUIVO VERDADEIRO
        file_name = "/home/lucas/mosaicode/extensions/mosaicode.model.blockmodel.xml"
        self.assertIsNone(self.blockpersistence.load(file_name))

        # TESTANDO COM NOME DE ARQUIVO VERDADEIRO MAS COM RETORNO
        file_name = "/home/lucas/mosaicode/extensions/mosaicode.model.blockmodel_teste.xml"
        self.assertIsNotNone(self.blockpersistence.load(file_name))

    # ----------------------------------------------------------------------x
    def test_save(self):
        # NÃO TRABALHA COM None
        # block = None
        # self.assertTrue(self.blockpersistence.save(block))

        diagram = Diagram(MainWindow())
        block = Block(diagram, None)
        self.assertTrue(self.blockpersistence.save(block))

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel(None)
        block = Block(diagram, blockmodel)
        block.type = "teste_blockpersistence"
        self.assertTrue(self.blockpersistence.save(block))

    # ----------------------------------------------------------------------x
    def test_save_python(self):

        # NÃO TRABALHA COM None
        # block = None
        # self.assertFalse(self.blockpersistence.save_python(block))

        diagram = Diagram(MainWindow())
        block = Block(diagram, None)
        self.assertTrue(self.blockpersistence.save_python(block))

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel(None)
        block = Block(diagram, blockmodel)
        block.type = "teste_blockpersistence"
        self.assertTrue(self.blockpersistence.save_python(block))
Ejemplo n.º 3
0
 def export_python(cls):
     from mosaicode.system import System
     System()
     blocks = System.get_blocks()
     for block in blocks:
         path = System.get_user_dir() + "/extensions/"
         path = path + block.language + "/" + block.framework + "/"
         BlockPersistence.save_python(blocks[block], path)
Ejemplo n.º 4
0
    def test_load_save(self):
        diagram_control = self.create_diagram_control()
        block = self.create_block(diagram_control)

        BlockPersistence.save_python(block, "/tmp/")
        file_name = "/tmp/" + block.label.lower().replace(' ', '_') + ".py"
        os.remove(file_name)

        BlockPersistence.save_xml(block, "/tmp/")
        file_name = "/tmp/" + block.type + ".xml"

        result = BlockPersistence.load_xml(file_name)
        os.remove(file_name)
Ejemplo n.º 5
0
 def export_python(cls):
     from mosaicode.system import System as System
     System()
     for plugin in System.plugins:
         print "Exporting plugin " + plugin
         BlockPersistence.save_python(System.plugins[plugin])
Ejemplo n.º 6
0
 def export_python(cls):
     from mosaicode.system import System as System
     System()
     for block in System.blocks:
         print "Exporting block " + block
         BlockPersistence.save_python(System.blocks[block])