def _import_opml(self, selected_file): opml_parser = OpmlParser() try: opml_parser.parse(selected_file) with open(self.file_path, 'a+') as links_file: for feed in opml_parser.feeds: if re.search(r'(.*), (.*)', feed): links_file.write(feed + '\n') else: self._throw_import_error() except KeyError: self._throw_import_error()
def test_opml_item(self): parser = OpmlParser() parser.parse('export_feeds_opml.opml') splited_item = parser.feeds[0].split(', ') self.assertEqual('PC Mania', splited_item[0]) self.assertEqual('http://pcmania.bg/feed.php', splited_item[1])
def test_opml_items(self): parser = OpmlParser() parser.parse('export_feeds_opml.opml') self.assertEqual(len(parser.feeds), 2)