tests.page_tests module#

Tests for the page module.

class tests.page_tests.HtmlEntity(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test that HTML entities are correctly decoded.

abstract_class = False#
test_ignore_entities()[source]#

Test ignore entities.

test_invalid_entities()[source]#

Test texts with invalid entities.

test_no_entities()[source]#

Test that text is left unchanged.

test_recursive_entities()[source]#

Test recursive entities.

test_valid_entities()[source]#

Test valid entities.

class tests.page_tests.TestApplicablePageProtections(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, TestCase

Test applicable restriction types.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_applicable_protections()[source]#

Test Page.applicable_protections.

class tests.page_tests.TestLinkObject(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, SiteAttributeTestCase

Test cases for Link objects.

abstract_class = False#
cached = True#
namespaces = {0: [''], 1: ['Talk:'], 2: ['User:'], 3: ['User talk:', 'User_talk:'], 4: ['Wikipedia:', 'Project:', 'WP:'], 5: ['Wikipedia talk:', 'Project talk:', 'Wikipedia_talk:', 'Project_talk:', 'WT:'], 6: ['File:'], 7: ['Image talk:', 'Image_talk:'], 8: ['MediaWiki:'], 9: ['MediaWiki talk:', 'MediaWiki_talk:'], 10: ['Template:'], 11: ['Template talk:', 'Template_talk:'], 12: ['Help:'], 13: ['Help talk:', 'Help_talk:'], 14: ['Category:'], 15: ['Category talk:', 'Category_talk:'], 100: ['Portal:'], 101: ['Portal talk:', 'Portal_talk:']}#
net = True#
site = True#
sites = {'enwiki': {'code': 'en', 'family': 'wikipedia'}, 'enws': {'code': 'en', 'family': 'wikisource'}, 'frwiki': {'code': 'fr', 'family': 'wikipedia'}, 'itwikt': {'code': 'it', 'family': 'wiktionary'}, 'itws': {'code': 'it', 'family': 'wikisource'}}#
testHashCmp()[source]#

Test hash comparison.

testNamespaces()[source]#

Test that Link() normalizes namespace names.

testTitles()[source]#

Test that Link() normalizes titles.

test_ns_title()[source]#

Test that title is returned with correct namespace.

titles = {'Cities in Burkina Faso': 'Cities in Burkina Faso', 'Hispanic  (U.S.  Census)': 'Hispanic (U.S. Census)', 'Nowy_Sącz': 'Nowy Sącz', 'Stołpce': 'Stołpce', 'The_Addams_Family_(pinball)': 'The Addams Family (pinball)', 'battle of Węgierska  Górka': 'Battle of Węgierska Górka', 'eastern Sayan': 'Eastern Sayan'}#
class tests.page_tests.TestPageBotMayEdit(*args, **kwargs)[source]#

Bases: RequireLoginMixin, CheckHostnameMixin, ForceCacheMixin, TestCase

Test Page.botMayEdit() method.

abstract_class = False#
cached = True#
code = 'test'#
family = 'wikipedia'#
login = True#
net = True#
setUp()[source]#

Setup test.

site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
tearDown()[source]#

Cleanup cache.

test_bot_may_edit_bots_nok()[source]#

Test with {{bots}} that bot is not allowed to edit.

test_bot_may_edit_bots_ok()[source]#

Test with {{bots}} that bot is allowed to edit.

test_bot_may_edit_inuse()[source]#

Test with {{in use}} that bot is allowed to edit.

test_bot_may_edit_missing_page()[source]#

Test botMayEdit for not existent page.

test_bot_may_edit_nobots_nok()[source]#

Test with {{nobots}} that bot is not allowed to edit.

test_bot_may_edit_nobots_ok()[source]#

Test with {{nobots}} that bot is allowed to edit.

test_bot_may_edit_page_nobots()[source]#

Test botMayEdit for existing page with nobots template.

test_bot_may_edit_page_set_text()[source]#

Test botMayEdit for existing page when assigning text first.

class tests.page_tests.TestPageCoordinates(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, TestCase

Test Page Object using German Wikipedia.

abstract_class = False#
cached = True#
code = 'de'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:de': {'code': 'de', 'family': 'wikipedia'}}#
test_coordinates()[source]#

Test Page.coodinates method.

class tests.page_tests.TestPageDelete(*args, **kwargs)[source]#

Bases: NeedRightsMixin, RequireLoginMixin, SiteWriteMixin, CheckHostnameMixin, TestCase

Test page delete / undelete actions.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
login = True#
net = True#
rights = 'delete'#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_delete()[source]#

Test the site.delete and site.undelete method.

write = True#
class tests.page_tests.TestPageGetFileHistory(*args, **kwargs)[source]#

Bases: DisconnectedSiteMixin, DefaultDrySiteTestCase

Test the get_file_history method of the FilePage class.

abstract_class = False#
code = 'test'#
dry = True#
family = 'wikipedia'#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_get_file_history_cache()[source]#

Test the cache mechanism of get_file_history.

class tests.page_tests.TestPageHistory(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, DefaultSiteTestCase

Test history related functionality.

abstract_class = False#
cached = True#
code = 'test'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_contributors()[source]#

Test Page.contributors().

test_revision_count()[source]#

Test Page.edit_count().

test_revisions()[source]#

Test Page.revisions().

test_revisions_time_interval_false()[source]#

Test Page.revisions() with reverse=False.

test_revisions_time_interval_true()[source]#

Test Page.revisions() with reverse=True.

class tests.page_tests.TestPageObject(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, DefaultSiteTestCase

Test Page object.

abstract_class = False#
cached = True#
code = 'test'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
testApiMethods()[source]#

Test various methods that rely on API.

testBasePageConstructor()[source]#

Test BasePage constructor.

testIsCategory()[source]#

Test is_categorypage method.

testIsDisambig()[source]#

Test the integration with Extension:Disambiguator.

testIsFile()[source]#

Test Page.is_filepage check.

testIsTalkPage()[source]#

Test isTalkPage() method.

Test the different types of links from a page.

testNamespace()[source]#

Test namespace() method.

testPageConstructor()[source]#

Test Page constructor.

testPickleAbility()[source]#

Test the ability to pickle the page.

testReferences()[source]#

Test references to a page.

testSection()[source]#

Test section() method.

testSite()[source]#

Test site() method.

testTitle()[source]#

Test title() method options in article namespace.

test_bad_page()[source]#

Test various methods that rely on API: bad page.

test_depth()[source]#

Test page depth calculation.

test_page_image()[source]#

Test Page.page_image function.

Since we are not sure what the wiki will return, we mainly test types

test_redirect()[source]#

Test that the redirect option is set correctly.

test_talk_page()[source]#

Test various methods that rely on API: talk page.

class tests.page_tests.TestPageObjectEnglish(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, TestCase

Test Page Object using English Wikipedia.

abstract_class = False#
cached = True#
code = 'en'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
testFileTitle()[source]#

Test title() method options in File namespace.

testGeneral()[source]#

Test general features of a page.

testHelpTitle()[source]#

Test title() method options in Help namespace.

testImageAndDataRepository()[source]#

Test image_repository and data_repository page attributes.

test_creation()[source]#

Test Page.oldest_revision.

test_old_version()[source]#

Test page.getOldVersion().

class tests.page_tests.TestPageProtect(*args, **kwargs)[source]#

Bases: NeedRightsMixin, RequireLoginMixin, SiteWriteMixin, CheckHostnameMixin, TestCase

Test page protect / unprotect actions.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
login = True#
net = True#
rights = 'protect'#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_protect()[source]#

Test Page.protect.

test_protect_alt()[source]#

Test of Page.protect that works around T78522.

test_protect_with_empty_parameters()[source]#

Test Page.protect.

write = True#
class tests.page_tests.TestPageRedirects(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, TestCase

Test redirects.

This is using the pages ‘User:Legoktm/R1’, ‘User:Legoktm/R2’ and ‘User:Legoktm/R3’ on the English Wikipedia. ‘R1’ is redirecting to ‘R2’, ‘R2’ is a normal page and ‘R3’ does not exist.

abstract_class = False#
cached = True#
net = True#
site = True#
sites = {'en': {'code': 'en', 'family': 'wikipedia'}, 'test': {'code': 'test', 'family': 'wikipedia'}}#
testIsRedirect()[source]#

Test Page.isRedirectPage() and Page.getRedirectTarget.

testIsStaticRedirect()[source]#

Test Page.isStaticRedirect().

testPageGet()[source]#

Test Page.get() on different types of pages.

test_set_redirect_target()[source]#

Test set_redirect_target method.

class tests.page_tests.TestPageRepr(*args, **kwargs)[source]#

Bases: DisconnectedSiteMixin, DefaultDrySiteTestCase

Test for Page’s repr implementation.

abstract_class = False#
code = 'test'#
dry = True#
family = 'wikipedia'#
classmethod setUpClass()[source]#

Initialize page instance.

site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
classmethod tearDownClass()[source]#

Restore the original console encoding.

test_type()[source]#

Test the return type of repr(Page(<page>)) is str.

test_value()[source]#

Test to capture actual Python result.

class tests.page_tests.TestPageUserAction(*args, **kwargs)[source]#

Bases: RequireLoginMixin, CheckHostnameMixin, DefaultSiteTestCase

Test page user actions.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
login = True#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_purge()[source]#

Test purging the mainpage.

test_watch()[source]#

Test Page.watch, with and without unwatch enabled.

Bases: CheckHostnameMixin, TestCase

Test that permalink links are correct.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#

Test permalink function.

Bases: RequireLoginMixin, CheckHostnameMixin, TestCase

Test that short link management is correct.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
login = True#
net = True#
site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#

Test create_short_link function.