def test_load_save(self):
        port = Port()
        port.label = "test"
        port.hint = "test"

        result = PortPersistence.load_xml("/this file does not exist")
        self.assertEquals(result, None)

        result = PortPersistence.save_xml(port, "/etc/")
        self.assertEquals(result, False)

        result = PortPersistence.save_xml(port, "/impossible to create")
        self.assertEquals(result, False)

        result = PortPersistence.save_xml(port, "/tmp/")
        self.assertEquals(result, True)

        file_name = "/tmp/" + port.hint + ".xml"
        result = PortPersistence.load_xml(file_name)
        os.remove(file_name)

        port.type = ""
        result = PortPersistence.save_xml(port, "/tmp/")
        file_name = "/tmp/" + port.hint + ".xml"
        result = PortPersistence.load_xml(file_name)
        self.assertEquals(result, None)
        os.remove(file_name)

        code_template = self.create_code_template()
        CodeTemplatePersistence.save_xml(code_template, "/tmp/")
        file_name = "/tmp/" + code_template.name + ".xml"
        result = PortPersistence.load_xml(file_name)
        os.remove(file_name)
    def test_save_xml(self):

        # Second condition
        file_name = "/tmp/" + self.code_template.type + ".xml"
        result = CodeTemplatePersistence.save_xml(self.code_template,
                                                  file_name)
        #        self.assertEquals(result, False)

        # Second condition
        port = Port()
        port.label = "test"
        PortPersistence.save_xml(port, "/tmp/")
        file_name = "/tmp/" + port.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
        #        self.assertNotEquals(result, True)
        #        os.remove(file_name)

        CodeTemplatePersistence.save_xml(self.code_template, "/tmp/")
        file_name = "/tmp/" + self.code_template.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
        self.assertEquals(result, None)
        #        os.remove(file_name)

        self.code_template.name = "Test"
        CodeTemplatePersistence.save_xml(self.code_template, "/tmp/")
        file_name = "/tmp/" + self.code_template.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
Exemplo n.º 3
0
 def add_port(cls, port):
     # first, save it
     from mosaicode.system import System as System
     System()
     path = System.get_user_dir() + "/extensions/"
     path = path + port.language + "/ports/"
     PortPersistence.save_xml(port, path)
Exemplo n.º 4
0
    def test_load(self):
        # First condition
        result = CodeTemplatePersistence.load_xml("This file does not exist")
        self.assertEquals(result, None)

        # Second condition
        port = Port()
        port.label = "test"
        PortPersistence.save_xml(port, "/tmp/")
        file_name = "/tmp/" + port.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
        self.assertNotEquals(result, True)
        os.remove(file_name)

        CodeTemplatePersistence.save_xml(self.code_template, "/tmp/")
        file_name = "/tmp/" + self.code_template.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
        self.assertEquals(result, None)
        os.remove(file_name)

        self.code_template.name = "Test"
        CodeTemplatePersistence.save_xml(self.code_template, "/tmp/")
        file_name = "/tmp/" + self.code_template.type + ".xml"
        result = CodeTemplatePersistence.load_xml(file_name)
        self.assertEquals(result.equals(self.code_template), True)
        os.remove(file_name)
 def test_load_wrong_file(self):
     port = Port()
     port.hint = "test"
     PortPersistence.save_xml(port, path="/tmp/")
     file_name = "/tmp/" + port.hint + ".xml"
     result = CodeTemplatePersistence.load_xml(file_name)
     self.assertNotEquals(result, True)
     os.remove(file_name)
Exemplo n.º 6
0
 def export_xml(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_xml(ports[port], path)
Exemplo n.º 7
0
 def export_xml(cls):
     from mosaicode.system import System as System
     System()
     ports = System.get_ports()
     for key in ports:
         path = System.get_user_dir()
         path = os.path.join(path, 'extensions', ports[key].language,
                             'ports')
         PortPersistence.save_xml(ports[key], path)
    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)
    def test_load_wrong_diagram(self):
        port = Port()
        port.hint = "test"
        PortPersistence.save_xml(port, path="/tmp/")
        file_name = "/tmp/" + port.hint + ".xml"
        result = DiagramPersistence.load(file_name)
        self.assertNotEquals(result, True)

        diagram = self.create_full_diagram()
        diagram.file_name = file_name
        result = DiagramPersistence.load(diagram)
        self.assertNotEquals(result, True)
        os.remove(file_name)