tests.proofreadpage_tests module#
Tests for the proofreadpage module.
- class tests.proofreadpage_tests.BS4TestCase(*args, **kwargs)[source]#
Bases:
TestCase
Run tests which needs bs4 beeing installed.
- abstract_class = True#
- class tests.proofreadpage_tests.TestBasePageMethodsIndexPage(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BS4TestCase
,BasePageMethodsTestBase
Test behavior of ProofreadPage methods inherited from BasePage.
- abstract_class = False#
- code = 'en'#
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestBasePageMethodsProofreadPage(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BasePageMethodsTestBase
Test behavior of ProofreadPage methods inherited from BasePage.
- abstract_class = False#
- code = 'en'#
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestIndexPageHasValidContent(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BS4TestCase
Unit tests for has_valid_content().
- abstract_class = False#
- code = 'en'#
- family = 'wikisource'#
- index_name = 'Index:Phosphor (1888).djvu'#
- net = True#
- other_template = '{{PoTM|bar=foobar}}'#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- test_has_valid_content_pre_and_postfixed()[source]#
Test pre- and postfixing Index template is invalid.
- valid_template = '{{:MediaWiki:Proofreadpage_index_template|foo=bar}}'#
- class tests.proofreadpage_tests.TestIndexPageInvalidSite(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test IndexPage class.
- abstract_class = False#
- cached = True#
- code = 'en'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.proofreadpage_tests.TestIndexPageMappings(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test IndexPage class.
- abstract_class = False#
- cached = True#
- net = True#
- site = True#
- sites = {'dews': {'code': 'de', 'family': 'wikisource', 'get_label': [120, 120, '120'], 'get_number': [[120, {120}]], 'index': 'Index:Musen-Almanach für das Jahr 1799', 'num_pages': 272, 'page': 'Seite:Schiller_Musenalmanach_1799_{0:3d}.jpg'}, 'enws': {'code': 'en', 'family': 'wikisource', 'get_label': [11, 11, '1'], 'get_number': [[1, {11}], ['Cvr', {1, 10, 804, 9}]], 'index': 'Index:Popular Science Monthly Volume 1.djvu', 'num_pages': 804, 'page': 'Page:Popular Science Monthly Volume 1.djvu/{0}'}, 'frws': {'code': 'fr', 'family': 'wikisource', 'get_label': [11, 11, '8'], 'get_number': [[8, {11}], ['-', {1, 2, 3, 101, 102, 103, 104, 105, 106, 107}]], 'index': 'Index:Segard - Hymnes profanes, 1894.djvu', 'num_pages': 107, 'page': 'Page:Segard - Hymnes profanes, 1894.djvu/{0}'}}#
- test_check_if_cached_dews()#
Test if cache is checked and loaded properly on wikisource:de
- test_check_if_cached_enws()#
Test if cache is checked and loaded properly on wikisource:en
- test_check_if_cached_frws()#
Test if cache is checked and loaded properly on wikisource:fr
- test_get_labels_dews()#
Test IndexPage page get_label_from_* functions on wikisource:de
- test_get_labels_enws()#
Test IndexPage page get_label_from_* functions on wikisource:en
- test_get_labels_frws()#
Test IndexPage page get_label_from_* functions on wikisource:fr
- test_get_page_and_number_dews()#
Test IndexPage page get_page_number functions on wikisource:de
- test_get_page_and_number_enws()#
Test IndexPage page get_page_number functions on wikisource:en
- test_get_page_and_number_frws()#
Test IndexPage page get_page_number functions on wikisource:fr
- test_num_pages_dews()#
Test num_pages property on wikisource:de
- test_num_pages_enws()#
Test num_pages property on wikisource:en
- test_num_pages_frws()#
Test num_pages property on wikisource:fr
- test_page_gen_dews()#
Test Index page generator on wikisource:de
- test_page_gen_enws()#
Test Index page generator on wikisource:en
- test_page_gen_frws()#
Test Index page generator on wikisource:fr
- class tests.proofreadpage_tests.TestIndexPageMappingsRedlinks(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test IndexPage mappings with redlinks.
- abstract_class = False#
- cached = True#
- code = 'en'#
- family = 'wikisource'#
- index_name = 'Index:Pywikibot test page.djvu'#
- missing_name = 'Page:Pywikibot test page.djvu/2'#
- net = True#
- page_names = ['Page:Pywikibot test page.djvu/1', 'Page:Pywikibot test page.djvu/2']#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestIndexPageValidSite(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test IndexPage class.
- abstract_class = False#
- cached = True#
- code = 'en'#
- existing_invalid_title = 'Main Page'#
- family = 'wikisource'#
- net = True#
- not_existing_invalid_title = 'User:cannot_exists'#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- test_invalid_existing_page_as_source()[source]#
Test IndexPage from invalid existing Page as source.
- test_invalid_not_existing_page_as_source()[source]#
Test IndexPage from Page not existing in non-Page ns as source.
- valid_index_title = 'Index:Popular Science Monthly Volume 1.djvu'#
- class tests.proofreadpage_tests.TestLoadRevisionsCachingIndexPage(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BS4TestCase
,BasePageLoadRevisionsCachingTestBase
Test site.loadrevisions() caching.
- abstract_class = False#
- cached = False#
- code = 'en'#
- property custom_text#
Return a dummy text for testing.
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestLoadRevisionsCachingProofreadPage(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BasePageLoadRevisionsCachingTestBase
Test site.loadrevisions() caching.
- abstract_class = False#
- cached = False#
- code = 'en'#
- property custom_text#
Return a dummy text for testing.
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestPageOCR(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test page ocr functions.
- abstract_class = False#
- cached = True#
- code = 'en'#
- data = {'googleOCR': (False, 'ENTERED, according to Act of Congress, in the year 1572,\nBY D. APPLETON & CO.\nIn the Office of the Librarian of Congress, at Washington.\n4 334\n'), 'hocr': (False, 'ENTERED, according to Act of Congress, in the year 1872,\nBY D. APPLETON & CO.,\nIn the Office of the Librarian of Congress, at Washington.\n\n'), 'ocr': (False, 'EsTEnen, according to Act of Congress, in the year 1872,\nBy D. APPLETON & CO.,\nIn the Office of the Librarian of Congress, at Washington.\n\x0c'), 'title': 'Page:Popular Science Monthly Volume 1.djvu/10', 'wmfOCR': (False, 'Estee, according to Act of Congress, in the year 1872,\nBy D. APPLETON & CO.,\nIn the Office of the Librarian of Congress, at Washington.')}#
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestPageQuality(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,TestCase
Test page quality.
- abstract_class = False#
- cached = True#
- code = 'en'#
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- class tests.proofreadpage_tests.TestProofreadPageIndexProperty(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,BS4TestCase
Test ProofreadPage index property.
- abstract_class = False#
- cached = True#
- code = 'en'#
- existing_multilinked = {'index_1': 'Index:Pywikibot test page.djvu', 'index_2': 'Index:Pywikibot test page 2', 'title': 'Page:Pywikibot test page.djvu/1'}#
- existing_unlinked = {'title': 'Page:Pywikibot unlinked test page'}#
- family = 'wikisource'#
- net = True#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
- valid = {'index': 'Index:Popular Science Monthly Volume 1.djvu', 'title': 'Page:Popular Science Monthly Volume 1.djvu/12'}#
- class tests.proofreadpage_tests.TestProofreadPageInvalidSite(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,TestCase
Test ProofreadPage class.
- abstract_class = False#
- cached = True#
- code = 'en'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.proofreadpage_tests.TestProofreadPageParseTitle(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,TestCase
Test ProofreadPage._parse_title() function.
- abstract_class = False#
- cached = True#
- net = True#
- site = True#
- sites = {'1': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test.djvu/12', 'tuple': ('Test.djvu', 'djvu', 12)}, '2': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test djvu/12', 'tuple': ('Test djvu', '', 12)}, '3': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test.jpg/12', 'tuple': ('Test.jpg', 'jpg', 12)}, '4': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test jpg/12', 'tuple': ('Test jpg', '', 12)}, '5': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test.jpg', 'tuple': ('Test.jpg', 'jpg', None)}, '6': {'code': 'en', 'family': 'wikisource', 'title': 'Page:Test jpg', 'tuple': ('Test jpg', '', None)}}#
- test_parse_title_1()#
Test ProofreadPage_parse_title() function on wikisource:en
- test_parse_title_2()#
Test ProofreadPage_parse_title() function on wikisource:en
- test_parse_title_3()#
Test ProofreadPage_parse_title() function on wikisource:en
- test_parse_title_4()#
Test ProofreadPage_parse_title() function on wikisource:en
- test_parse_title_5()#
Test ProofreadPage_parse_title() function on wikisource:en
- test_parse_title_6()#
Test ProofreadPage_parse_title() function on wikisource:en
- class tests.proofreadpage_tests.TestProofreadPageValidSite(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,TestCase
Test ProofreadPage class.
- abstract_class = False#
- cached = True#
- class_pagetext_fmt = {False: ('', ''), True: ('<div class="pagetext">\n\n\n', '</div>')}#
- code = 'en'#
- existing_invalid = {'title': 'Main Page'}#
- existing_unlinked = {'title': 'Page:Pywikibot unlinked test page'}#
- family = 'wikisource'#
- fmt = '<noinclude><pagequality level="1" user="{user}" />{class_pagetext}</noinclude><noinclude>{references}{div_end}</noinclude>'#
- net = True#
- not_existing_invalid = {'title': 'User:cannot_exists', 'title1': 'User:Popular Science Monthly Volume 1.djvu/12'}#
- site = True#
- sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
Test ProofreadPage page parsing functions.
- test_invalid_existing_page_source()[source]#
Test ProofreadPage from invalid existing Page as source.
- test_invalid_not_existing_page_source()[source]#
Test ProofreadPage from invalid not existing Page as source.
- test_invalid_not_existing_page_source_wrong_ns()[source]#
Test ProofreadPage from Page not existing in non-Page ns.
- valid = {'footer': '\n{{smallrefs}}', 'header': "{{rh|2|''THE POPULAR SCIENCE MONTHLY.''}}", 'index': 'Index:Popular Science Monthly Volume 1.djvu', 'ql': 4, 'title': 'Page:Popular Science Monthly Volume 1.djvu/12', 'url_image': 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Popular_Science_Monthly_Volume_1.djvu/page12-1024px-Popular_Science_Monthly_Volume_1.djvu.jpg', 'user': 'T. Mazzei'}#
- valid_redlink = {'title': 'Page:Pywikibot test page 3.jpg', 'url_image': 'https://upload.wikimedia.org/wikisource/en/3/37/Pywikibot_test_page_3.jpg'}#