XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230394
Change subject: [IMPROV] Test unconnected page generators
......................................................................
[IMPROV] Test unconnected page generators
Add tests to the newly introduced generators from f166999f.
Change-Id: I7204ab8da0feab9e9211c36ad9d5e2dcabd96eb0
---
M tests/pagegenerators_tests.py
M tests/site_tests.py
2 files changed, 36 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/94/230394/1
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index dccd20c..ce51bfc 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -905,6 +905,31 @@
"user", "bot"]:
self.assertIn(key, rcinfo.keys())
+
+class TestUnconnectedPageGenerator(DefaultSiteTestCase):
+
+ """Test UnconnectedPageGenerator."""
+
+ def test_unconnected_with_repo(self):
+ """Test that the ItemPage returned raises NoPage."""
+ if not self.site.data_repository():
+ raise unittest.SkipTest('Site is not using a Wikibase repository')
+ cnt = 0
+ for page in pagegenerators.UnconnectedPageGenerator(self.site,
total=5):
+ self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
+ page)
+ cnt += 1
+ self.assertLessEqual(cnt, 5)
+
+ def test_unconnected_without_repo(self):
+ """Test that it raises a ValueError on sites without repository."""
+ if self.site.data_repository():
+ raise unittest.SkipTest('Site is using a Wikibase repository')
+ with self.assertRaises(ValueError):
+ for page in pagegenerators.UnconnectedPageGenerator(self.site,
+ total=5):
+ assert False # this shouldn't be reached
+
if __name__ == "__main__":
try:
unittest.main()
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 0b9c726..5e3db05 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -811,6 +811,17 @@
self.assertNotIn(page.protection()['edit'][0], invalid_levels)
self.assertLessEqual(len(pages), 10)
+ def test_unconnected(self):
+ """Test that the ItemPage returned raises NoPage."""
+ if not self.site.data_repository():
+ raise unittest.SkipTest('Site is not using a Wikibase repository')
+ cnt = 0
+ for page in self.site.unconnected_pages(total=5):
+ self.assertRaises(pywikibot.NoPage, pywikibot.ItemPage.fromPage,
+ page)
+ cnt += 1
+ self.assertLessEqual(cnt, 5)
+
class TestImageUsage(DefaultSiteTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/230394
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7204ab8da0feab9e9211c36ad9d5e2dcabd96eb0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits