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)
Exemple #2
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)
Exemple #3
0
 def add_code_template(cls, code_template):
     # save it
     from mosaicode.system import System as System
     System()
     path = System.get_user_dir() + "/extensions/"
     path = path + code_template.language + "/"
     CodeTemplatePersistence.save_xml(code_template, path)
    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_exception(self):
     result = CodeTemplatePersistence.save_xml(self.code_template,
                                               path="/nao")
     self.assertEquals(result, False)
     result = CodeTemplatePersistence.save_xml(self.code_template,
                                               path="/etc")
     self.assertEquals(result, False)
 def test_load_save_empty(self):
     self.code_template.name = ""
     self.code_template.type = ""
     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("/tmp/.xml")
Exemple #7
0
 def export_xml(cls):
     from mosaicode.system import System as System
     System()
     code_templates = System.get_code_templates()
     for code_template in code_templates:
         path = System.get_user_dir() + "/extensions/"
         path = path + code_template.language + "/"
         CodeTemplatePersistence.save_xml(code_templates[code_template])
Exemple #8
0
 def export_xml(cls):
     from mosaicode.system import System as System
     System()
     code_templates = System.get_code_templates()
     for key in code_templates:
         path = System.get_user_dir()
         path = os.path.join(path, 'extensions',
                             code_templates[key].language, 'codetemplates')
         CodeTemplatePersistence.save_xml(code_templates[key], path)
Exemple #9
0
    def test_load_save(self):
        System()
        prefs = System.get_preferences()
        PreferencesPersistence.save(prefs, "/tmp")
        PreferencesPersistence.save(prefs, "/etc")
        PreferencesPersistence.load("/tmp")
        PreferencesPersistence.load("/not")
        os.remove("/tmp/" + prefs.conf_file_path)

        code_template = self.create_code_template()
        code_template.name = "configuration"
        CodeTemplatePersistence.save_xml(code_template, "/tmp/")
        result = PreferencesPersistence.load("/tmp")
        file_name = "/tmp/" + code_template.name + ".xml"
        os.remove(file_name)
 def test_save_wrong_dir(self):
     result = CodeTemplatePersistence.save_xml(self.code_template,
                                               path="/nao")
     self.assertEquals(result, False)
 def test_load_save_empty(self):
     result = CodeTemplatePersistence.save_xml(self.code_template,
                                               path=None)
     self.assertEquals(result, False)
 def test_load_save(self):
     self.code_template = self.create_code_template()
     CodeTemplatePersistence.save_xml(self.code_template, "/tmp/")
     file_name = "/tmp/" + self.code_template.name + ".xml"
     result = CodeTemplatePersistence.load_xml(file_name)
     os.remove(file_name)