def test_category_format_Page(self): data = [ pywikibot.Page(self.site, 'Category:Cat1'), pywikibot.Page(self.site, 'Category:Cat2') ] self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
def test_category_format_Page(self): """Test formatting categories as Page instances.""" data = [ pywikibot.Page(self.site, 'Category:Cat1'), pywikibot.Page(self.site, 'Category:Cat2') ] self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
def handle_single_page(self): """ Determine action to perform on page. Effectively this is done by setting self.text if an update is needed/possible. @todo: handle Unresolved better :return: String describing action """ log_entry = None # determine action if self.content_not_changed(): return "No change from original" # no need to do an update elif self.has_only_one_revision(): self.text = self.new_text # just replace contents return "One revision" elif self.only_cats_differ(): log_entry = "Only categories" final_cats = self.get_final_categories() # replace cats in new_text with final cats self.text = "{text}\n\n{catgories}".format( text=self.remove_cats_and_comments(self.new_text), catgories=textlib.categoryFormat(final_cats)) else: # This will also catch any already updated pages log_entry = "Unresolved" pass # don't know what to do if self.text and self.text == self.page.text or \ self.new_text == self.page.text: # Either by coincidence or due to a previous run self.text = None return "No change from final version" else: return log_entry
def test_category_format_Page(self): """Test formatting categories as Page instances.""" data = [pywikibot.Page(self.site, 'Category:Cat1'), pywikibot.Page(self.site, 'Category:Cat2')] self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
def test_category_format_bare(self): """Test formatting categories as strings.""" self.assertEqual(self.catresult, textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
def test_category_format_raw(self): """Test formatting categories as strings formatted as links.""" self.assertEqual(self.catresult, textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'], self.site))
def test_category_format_Page(self): data = [pywikibot.Page(self.site, "Category:Cat1"), pywikibot.Page(self.site, "Category:Cat2")] self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
def test_category_format_bare(self): self.assertEqual(self.catresult, textlib.categoryFormat(["Cat1", "Cat2"], self.site))
def test_category_format_bare(self): self.assertEqual(self.catresult, textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
def test_categoryFormat_Category(self): self.assertEqual(self.catresult1, textlib.categoryFormat(self.data, self.site))
def test_categoryFormat_bare(self): self.assertEqual(self.catresult1, textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
def test_categoryFormat_raw(self): self.assertEqual(self.catresult1, textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'], self.site))
def test_category_format_Category(self): data = [pywikibot.Category(self.site, 'Cat1'), pywikibot.Category(self.site, 'Cat2')] self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
def test_category_format_raw(self): self.assertEqual( self.catresult, textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'], self.site))
def test_categoryFormat_Page(self): data = [pywikibot.Page(self.site, 'Category:Cat1'), pywikibot.Page(self.site, 'Category:Cat2')] self.assertEqual(self.catresult1, textlib.categoryFormat(self.data, self.site))
def test_category_format_raw(self): self.assertEqual(self.catresult, textlib.categoryFormat(["[[Category:Cat1]]", "[[Category:Cat2]]"], self.site))
def test_category_format_raw(self): """Test formatting categories as strings formatted as links.""" self.assertEqual( self.catresult, textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'], self.site))