http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11265
Revision: 11265 Author: legoktm Date: 2013-03-25 13:22:19 +0000 (Mon, 25 Mar 2013) Log Message: ----------- Start Wikibase unittests, minor PEP8 fix
Modified Paths: -------------- branches/rewrite/tests/page_tests.py branches/rewrite/tests/site_tests.py
Modified: branches/rewrite/tests/page_tests.py =================================================================== --- branches/rewrite/tests/page_tests.py 2013-03-25 12:29:15 UTC (rev 11264) +++ branches/rewrite/tests/page_tests.py 2013-03-25 13:22:19 UTC (rev 11265) @@ -14,7 +14,7 @@ import pywikibot import pywikibot.page
-site = pywikibot.Site('en') +site = pywikibot.Site('en', 'wikipedia') mainpage = pywikibot.Page(pywikibot.page.Link("Main Page", site)) maintalk = pywikibot.Page(pywikibot.page.Link("Talk:Main Page", site)) badpage = pywikibot.Page(pywikibot.page.Link("There is no page with this title", @@ -268,6 +268,21 @@ for p in mainpage.extlinks(): self.assertTrue(isinstance(p, unicode))
+ def testWikibase(self): + if not site.has_transcluded_data: + return + repo = site.data_repository() + item = pywikibot.ItemPage.fromPage(mainpage) + self.assertTrue(item.getID(), 'q5296') + self.assertTrue('en' in item.labels) + self.assertEqual(item.labels['en'], 'Main Page') + self.assertTrue('en' in item.aliases) + self.assertTrue('HomePage' in item.aliases['en']) + prop = pywikibot.PropertyPage(repo, 'Property:P21') + self.assertEqual(prop.getType(), 'wikibase-item') + + + # methods that still need tests implemented or expanded:
## def autoFormat(self):
Modified: branches/rewrite/tests/site_tests.py =================================================================== --- branches/rewrite/tests/site_tests.py 2013-03-25 12:29:15 UTC (rev 11264) +++ branches/rewrite/tests/site_tests.py 2013-03-25 13:22:19 UTC (rev 11265) @@ -45,7 +45,7 @@ self.assertEqual(mysite.family.name, self.family) self.assertEqual(mysite.code, self.code) self.assertType(mysite.lang, basestring) - self.assertType(mysite == pywikibot.Site("en", "wikipedia"), bool) + self.assertEqual(mysite, pywikibot.Site("en", "wikipedia")) self.assertType(mysite.user(), (basestring, type(None))) self.assertEqual(mysite.sitename(), "%s:%s" % (self.family, @@ -74,7 +74,7 @@ self.assertTrue(mysite.code in langs) obs = mysite.family.obsolete ipf = mysite.interwiki_putfirst() - if ipf: #Not all languages use this + if ipf: # Not all languages use this self.assertType(ipf, list)
for item in mysite.validLanguageLinks():
pywikipedia-svn@lists.wikimedia.org