def test_xmlarticle_meta_keywords_without_data_pipe(self): fakexylosearticle = Article({ 'article': { 'v40': [{ '_': 'pt' }] }, 'title': {} }) pxml = ET.Element('records') pxml.append(ET.Element('record')) data = [fakexylosearticle, pxml] xmlarticle = export_doaj.XMLArticleMetaKeywordsPipe() raw, xml = xmlarticle.transform(data) try: xml.find('./record/keywords').text except AttributeError: self.assertTrue(True) else: self.assertTrue(False)
def test_xmlarticle_meta_keywords_pipe(self): pxml = ET.Element('records') pxml.append(ET.Element('record')) data = [self._article_meta, pxml] xmlarticle = export_doaj.XMLArticleMetaKeywordsPipe() raw, xml = xmlarticle.transform(data) keywords = sorted([ i.text.encode('utf-8') for i in xml.findall('./record/keywords/keyword') ]) self.assertEqual( sorted([ i.encode('utf-8') for i in [ 'Renal Insufficiency, Chronic', 'Renal Replacement Therapy', 'Hospital Information Systems', 'Mortality Registries', 'Insuficiencia Renal Crónica', 'Terapia de Reemplazo Renal', 'Sistemas de Información en Hospital', 'Registros de Mortalidad', 'Insuficiência Renal Crônica', 'Terapia de Substituição Renal', 'Sistemas de Informação Hospitalar', 'Registros de Mortalidade' ] ]), keywords)
def pipeline_doaj(self): xylose_article = Article(self._article, iso_format='iso 639-2') ppl = plumber.Pipeline(export_doaj.SetupArticlePipe(), export_doaj.XMLArticlePipe(), export_doaj.XMLJournalMetaPublisherPipe(), export_doaj.XMLJournalMetaJournalTitlePipe(), export_doaj.XMLJournalMetaISSNPipe(), export_doaj.XMLArticleMetaPublicationDatePipe(), export_doaj.XMLArticleMetaVolumePipe(), export_doaj.XMLArticleMetaIssuePipe(), export_doaj.XMLArticleMetaStartPagePipe(), export_doaj.XMLArticleMetaEndPagePipe(), export_doaj.XMLArticleMetaArticleIdDOIPipe(), export_doaj.XMLArticleMetaIdPipe(), export_doaj.XMLArticleMetaDocumentTypePipe(), export_doaj.XMLArticleMetaTitlePipe(), export_doaj.XMLArticleMetaAuthorsPipe(), export_doaj.XMLArticleMetaAffiliationPipe(), export_doaj.XMLArticleMetaAbstractsPipe(), export_doaj.XMLArticleMetaFullTextUrlPipe(), export_doaj.XMLArticleMetaKeywordsPipe(), export_doaj.XMLClosePipe()) transformed_data = ppl.run(xylose_article, rewrap=True) return next(transformed_data)
def test_xmlarticle_meta_keywords_languages_data_pipe(self): pxml = ET.Element('records') pxml.append(ET.Element('record')) data = [self._article_meta, pxml] xmlarticle = export_doaj.XMLArticleMetaKeywordsPipe() raw, xml = xmlarticle.transform(data) keywords_language = [ i.get('language') for i in xml.findall('./record/keywords') ] self.assertEqual([u'en', u'es', u'pt'], keywords_language)
def test_xmlarticle_meta_keywords_languages_data_pipe(self): pxml = ET.Element('records') pxml.append(ET.Element('record')) data = [self._article_meta, pxml] xmlarticle = export_doaj.XMLArticleMetaKeywordsPipe() raw, xml = xmlarticle.transform(data) keywords_language = sorted([ i.get('language').encode('utf-8') for i in xml.findall('./record/keywords') ]) self.assertEqual( sorted([ 'en'.encode('utf-8'), 'es'.encode('utf-8'), 'pt'.encode('utf-8') ]), keywords_language)