jenkins-bot has submitted this change and it was merged.
Change subject: flow: Add Page.is_flow_page() which checks contentmodel ......................................................................
flow: Add Page.is_flow_page() which checks contentmodel
Don't use flowinfo, we can get the same information by checking the content model.
Change-Id: I8f49a609c03d30d3fd5d7ed98b353c9eaae28405 --- M pywikibot/page.py M pywikibot/site.py M tests/page_tests.py 3 files changed, 33 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index a10291f..1204fdc 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -1782,16 +1782,17 @@ u'required.' % self.title(asLink=True)) return False
+ @deprecated('Page.is_flow_page()') def isFlowPage(self): - """Whether the given title is a Flow page. + return self.isFlowPage()
- @return: bool + def is_flow_page(self): """ - if not self.site.has_extension('Flow'): - return False - if not hasattr(self, '_flowinfo'): - self.site.loadflowinfo(self) - return 'enabled' in self._flowinfo + Whether a page is a Flow page. + + @rtype: bool + """ + return self.content_model == 'flow-board'
# ####### DEPRECATED METHODS ########
diff --git a/pywikibot/site.py b/pywikibot/site.py index 3c3149c..c388187 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2399,6 +2399,7 @@ return (pageitem['imageinfo'] if history else pageitem['imageinfo'][0])
+ @deprecated('Check the content model instead') def loadflowinfo(self, page): """ Load Flow-related information about a given page. diff --git a/tests/page_tests.py b/tests/page_tests.py index 63e5e32..2aa20b7 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -550,6 +550,30 @@ self.assertRaises(pywikibot.exceptions.NoPage, p3.get)
+class TestFlow(TestCase): + + """Test Flow pages using Page layer.""" + + family = 'mediawiki' + code = 'mediawiki' + + cached = True + + def test_methods(self): + """Test basic Page methods on a Flow page.""" + site = self.get_site() + page = pywikibot.Page(site, u'Talk:Sandbox') + self.assertEqual(page.exists(), True) + page.get() + self.assertEqual(page.isRedirectPage(), False) + + def test_content_model(self): + """Test Flow page content model.""" + site = self.get_site() + page = pywikibot.Page(site, u'Talk:Sandbox') + self.assertEqual(page.content_model, 'flow-board') + + class TestPageUserAction(DefaultSiteTestCase):
"""Test page user actions."""