Ejemplo n.º 1
0
 def get(self):
     pages = self.wiki_data.list_pages()
     pages.sort("url")
     urls = [p["url"] for p in pages]
     parent_path = self.get_argument("parent_path")
     subjects = wikidata.get_next_path(parent_path, urls)
     self.write(json.dumps(subjects));
Ejemplo n.º 2
0
 def test_get_next_path(self):
     target = self.urls
     r = wikidata.get_next_path("a", target)
     self.assertEqual(len(r), 2)
     self.assertEqual(r, ['test1', 'test2'])
     r = wikidata.get_next_path("wikihome", target)
     self.assertEqual(len(r), 0)
     self.assertEqual(r, [])
     r = wikidata.get_next_path("/wikihome", target)
     self.assertEqual(len(r), 0)
     self.assertEqual(r, [])
     r = wikidata.get_next_path("/b/test1", target)
     self.assertEqual(len(r), 2)
     self.assertEqual(r, ['2_AAA', '2_BBB'])
     r = wikidata.get_next_path("/notexist", target)
     self.assertEqual(len(r), 0)
     self.assertEqual(r, [])