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#
classmethod setUpClass()[source]#

Check whether bs4 module is installed already.

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#
setUp()[source]#

Set up test case.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_basepage_methods()[source]#

Test IndexPage methods inherited from superclass BasePage.

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#
setUp()[source]#

Set up test case.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_basepage_methods()[source]#

Test ProofreadPage methods inherited from superclass BasePage.

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}}'#
classmethod setUpClass()[source]#

Prepare tests by creating an IndexPage instance.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_has_valid_content_empty()[source]#

Test empty page is invalid.

test_has_valid_content_missnamed_template()[source]#

Test nested templates is valid.

test_has_valid_content_multiple_valid()[source]#

Test multiple Index templates is invalid.

test_has_valid_content_nested_template()[source]#

Test nested templates is valid.

test_has_valid_content_non_template()[source]#

Test non-template is invalid.

test_has_valid_content_postfixed()[source]#

Test postfixing Index template is invalid.

test_has_valid_content_pre_and_postfixed()[source]#

Test pre- and postfixing Index template is invalid.

test_has_valid_content_prefixed()[source]#

Test prefixing Index template is invalid.

test_has_valid_content_second_template()[source]#

Test postfixing a second template is invalid.

test_has_valid_content_valid()[source]#

Test correct Index template is valid.

test_has_valid_content_wrong_template()[source]#

Test incorrect 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'}}#
test_invalid_site_source()[source]#

Test IndexPage from invalid Site as source.

class tests.proofreadpage_tests.TestIndexPageMappings(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, ForceCacheMixin, BS4TestCase

Test IndexPage class.

abstract_class = False#
cached = True#
net = True#
classmethod setUpClass()[source]#

Prepare get_page dataset for tests.

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

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']#
classmethod setUpClass()[source]#

Prepare tests by creating page instances.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#

Test IndexPage page get_page_number functions with redlinks.

Test index property with redlink.

Test Index page generator with redlinks.

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 IndexPage from invalid Link as source.

test_invalid_not_existing_page_as_source()[source]#

Test IndexPage from Page not existing in non-Page ns as source.

Test IndexPage from valid Link as source.

test_valid_site_as_source()[source]#

Test IndexPage from valid Site 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#
setUp()[source]#

Set up test case.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_page_text()[source]#

Test site.loadrevisions() with Page.text.

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#
setUp()[source]#

Set up test case.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_page_text()[source]#

Test site.loadrevisions() with Page.text.

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#
setUp()[source]#

Test setUp.

site = True#
sites = {'wikisource:en': {'code': 'en', 'family': 'wikisource'}}#
test_do_hocr()[source]#

Test page._do_hocr().

test_do_ocr_googleocr()[source]#

Test page._do_ocr(ocr_tool=’googleOCR’).

test_do_ocr_phetools()[source]#

Test page._do_ocr(ocr_tool=’phetools’).

test_do_ocr_wmfocr()[source]#

Test page._do_ocr(ocr_tool=’wmfOCR’).

test_ocr_exceptions()[source]#

Test page.ocr() exceptions.

test_ocr_wmfocr()[source]#

Test page.ocr(ocr_tool=’wmfOCR’).

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'}}#
test_applicable_quality_level()[source]#

Test Page.quality_level when applicable.

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'}}#
test_index()[source]#

Test index property.

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'}}#
test_invalid_site_source()[source]#

Test ProofreadPage from invalid Site as source.

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_decompose_recompose_text()[source]#

Test ProofreadPage page decomposing/composing text.

Test ProofreadPage page parsing functions.

test_invalid_existing_page_source()[source]#

Test ProofreadPage from invalid existing Page as source.

Test ProofreadPage from invalid Link 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.

test_json_format()[source]#

Test conversion to json format.

test_preload_from_empty_text()[source]#

Test ProofreadPage page decomposing/composing text.

test_preload_from_not_existing_page()[source]#

Test ProofreadPage page decomposing/composing text.

test_url_image()[source]#

Test fetching of url image of the scan of ProofreadPage.

Test ProofreadPage from valid Link as source.

test_valid_parsing()[source]#

Test ProofreadPage page parsing functions.

test_valid_site_source()[source]#

Test ProofreadPage from valid Site as source.

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'}#