Exemplo n.º 1
0
 def export_python(cls):
     from mosaicode.system import System as System
     System()
     ports = System.get_ports()
     for port in ports:
         path = System.get_user_dir() + "/extensions/"
         path = path + port.language + "/ports/"
         PortPersistence.save_python(ports[port])
Exemplo n.º 2
0
class TestPortPersistence(TestCase):
    def setUp(self):
        """Do the test basic setup."""
        self.portpersistence = PortPersistence()

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

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

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

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

        # TESTANDO COM NOME DE ARQUIVO FALSO DE XML
        file_name = "/home/lucas/mosaicode/extensions/mosaicode.model.portmodel.xml"
        self.assertIsNone(self.portpersistence.load(file_name))

        # TESTANDO COM ARQUIVO COM port.type = ""
        file_name = "/home/lucas/mosaicode/extensions/mosaicode.model.port_teste.xml"
        self.assertIsNone(self.portpersistence.load(file_name))

        # TESTANDO COM NOME DE ARQUIVO VERDADEIRO
        file_name = "/home/lucas/mosaicode/extensions/ports/mosaicode.model.port.xml"
        self.assertIsNotNone(self.portpersistence.load(file_name))

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

        port = Port()
        self.assertTrue(self.portpersistence.save(port))

        port.type = "teste_portpersistence"
        self.assertTrue(self.portpersistence.save(port))

        # NÃO TRABALHA COM None
        # port = None
        # self.assertFalse(self.portpersistence.save(port))

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

        port = Port()
        self.assertTrue(self.portpersistence.save_python(port))

        port.type = "teste_portpersistence"
        self.assertTrue(self.portpersistence.save_python(port))
    def test_load_save(self):
        port = Port()
        port.label = "test"

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

        PortPersistence.save_xml(port, "/tmp/")
        file_name = "/tmp/" + port.type + ".xml"

        result = PortPersistence.load_xml(file_name)
Exemplo n.º 4
0
 def export_python(cls):
     from mosaicode.system import System as System
     System()
     ports = System.get_ports()
     for port in ports:
         PortPersistence.save_python(ports[port])
Exemplo n.º 5
0
 def export_python(cls):
     from mosaicode.system import System as System
     System()
     for port in System.ports:
         print "Exporting port " + port
         PortPersistence.save_python(System.ports[port])