def test_parser_serialization(self): parser1 = RegexParserFactory.create_from_intent(self.parser_intent1) parser2 = RegexParserFactory.create_from_intent(self.parser_intent2) parser3 = RegexParserFactory.create_from_intent(self.parser_intent3) parsers_list = [parser1, parser2, parser3] parsers_dao_list = [parser.serialize() for parser in parsers_list] dumped_parsers = yaml.dump_all(parsers_dao_list, explicit_start=True) loaded_parsers = [ RegexParserFactory.from_dao(dumped_parser) for dumped_parser in yaml.load_all(dumped_parsers) ] dumped_parsers_again = yaml.dump_all( [parser.serialize() for parser in loaded_parsers], explicit_start=True) assert dumped_parsers_again == dumped_parsers
def test_parser_serialization(self): parser1 = RegexParserFactory.create_from_intent(self.parser_intent1) parser2 = RegexParserFactory.create_from_intent(self.parser_intent2) parser3 = RegexParserFactory.create_from_intent(self.parser_intent3) parsers_list = [parser1, parser2, parser3] parsers_dao_list = [parser.serialize() for parser in parsers_list] dumped_parsers = yaml.dump_all(parsers_dao_list, explicit_start=True) loaded_parsers = [ RegexParserFactory.from_dao(dumped_parser) for dumped_parser in yaml.load_all(dumped_parsers) ] dumped_parsers_again = yaml.dump_all( [parser.serialize() for parser in loaded_parsers], explicit_start=True ) assert dumped_parsers_again == dumped_parsers
def _load_parsers(self): return dict( (parser_definition["name"], RegexParserFactory.from_dao(parser_definition)) for parser_definition in self._load_file_with_config(self._parsers_path) )
def _load_parsers(self): return dict((parser_definition["name"], RegexParserFactory.from_dao(parser_definition)) for parser_definition in self._load_file_with_config( self._parsers_path))