def load(cls, file_name): """ This method loads the code_template from XML file. Returns: * **Types** (:class:`boolean<boolean>`) """ # load the code_template if os.path.exists(file_name) is False: return parser = XMLParser(file_name) if parser.getTag(tag_name) is None: return None try: code_template = CodeTemplate() code_template.name = parser.getTagAttr(tag_name, "name") code_template.type = parser.getTagAttr(tag_name, "type") code_template.description = parser.getTagAttr( tag_name, "description") code_template.language = parser.getTagAttr(tag_name, "language") code_template.extension = parser.getTagAttr(tag_name, "extension") code_template.source = parser.getTagAttr(tag_name, "source") code_template.command = parser.getTag(tag_name).getTag( "command").getText() code_template.code = parser.getTag(tag_name).getTag( "code").getText() except: return None if code_template.name == "": return None return code_template
def test_add_code_template(self): #code_template = None #self.assertIsNone(self.main_control.add_code_template(code_template)) from mosaicode.model.codetemplate import CodeTemplate code_template = CodeTemplate() code_template.type = "c" code_template.name = "TESTE" code_template.source = "xml" self.assertIsNone(self.main_control.add_code_template(code_template))
def test_add_code_template(self): code_template = CodeTemplate() self.assertIsNone( self.codetemplatemanager.add_code_template(code_template)) code_template.type = "Language Test" code_template.name = "Testando Code Template" code_template.description = "Um teste para code template em Add Code Template" code_template.language = "" code_template.command = "" code_template.extension = "teste" code_template.code = "Testando 1 2 3" code_template.source = "python" self.assertIsNone( self.codetemplatemanager.add_code_template(code_template))