def test_get_wikilink(self):
     html = """
     <div>
         <div>
             <ul class="wikibase-sitelinklistview-listview">
                 <li data-wb-siteid="arwiki"><a href="http://ar.wikipedia.org/wiki/Test">Test</a></li>
                 <li data-wb-siteid="enwiki"><a href="http://en.wikipedia.org/wiki/Test">Test</a></li>
             </ul>
         </div>
         <div>
             <ul class="wikibase-sitelinklistview-listview">
                 <li data-wb-siteid="enwikiquote"><a href="https://en.wikiquote.org/wiki/Test">Test</a></li>
             </ul>
         </div>
     </div>
     """
     html_etree = fromstring(html)
     wikilink = wikidata.get_wikilink(html_etree, 'nowiki')
     self.assertEqual(wikilink, None)
     wikilink = wikidata.get_wikilink(html_etree, 'enwiki')
     self.assertEqual(wikilink, 'https://en.wikipedia.org/wiki/Test')
     wikilink = wikidata.get_wikilink(html_etree, 'arwiki')
     self.assertEqual(wikilink, 'https://ar.wikipedia.org/wiki/Test')
     wikilink = wikidata.get_wikilink(html_etree, 'enwikiquote')
     self.assertEqual(wikilink, 'https://en.wikiquote.org/wiki/Test')
Ejemplo n.º 2
0
 def test_get_wikilink(self):
     html = """
     <div>
         <div>
             <ul class="wikibase-sitelinklistview-listview">
                 <li data-wb-siteid="arwiki"><a href="http://ar.wikipedia.org/wiki/Test">Test</a></li>
                 <li data-wb-siteid="enwiki"><a href="http://en.wikipedia.org/wiki/Test">Test</a></li>
             </ul>
         </div>
         <div>
             <ul class="wikibase-sitelinklistview-listview">
                 <li data-wb-siteid="enwikiquote"><a href="https://en.wikiquote.org/wiki/Test">Test</a></li>
             </ul>
         </div>
     </div>
     """
     html_etree = fromstring(html)
     wikilink = wikidata.get_wikilink(html_etree, 'nowiki')
     self.assertEqual(wikilink, None)
     wikilink = wikidata.get_wikilink(html_etree, 'enwiki')
     self.assertEqual(wikilink, 'https://en.wikipedia.org/wiki/Test')
     wikilink = wikidata.get_wikilink(html_etree, 'arwiki')
     self.assertEqual(wikilink, 'https://ar.wikipedia.org/wiki/Test')
     wikilink = wikidata.get_wikilink(html_etree, 'enwikiquote')
     self.assertEqual(wikilink, 'https://en.wikiquote.org/wiki/Test')