Page MenuHomePhabricator

proofread page tests fail if username is not present
Closed, ResolvedPublic

Description

Rather than fail badly, they should fail in the class constructor or the test framework might be able to simply set a dummy username as these tests do not write so it shouldnt attempt to log in.

======================================================================
ERROR: test_check_if_cached_enws (tests.proofreadpage_tests.TestIndexPageMappings)
Test if cache is checked and loaded properly on wikisource:en
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/aspects.py", line 688, in wrapped_method
    func(self, key)
  File "tests/proofreadpage_tests.py", line 456, in test_check_if_cached
    fetched_label = index_page.get_label_from_page_number(num)
  File "pywikibot/proofreadpage.py", line 471, in wrapper
    self._get_page_mappings()
  File "pywikibot/proofreadpage.py", line 514, in _get_page_mappings
    self.purge()
  File "pywikibot/page.py", line 1299, in purge
    return self.site.purgepages([self], **kwargs)
  File "pywikibot/site.py", line 1299, in callee
    self.login(False)
  File "pywikibot/site.py", line 2058, in login
    user=self._username[sysop])
  File "pywikibot/tools/__init__.py", line 1357, in wrapper
    return obj(*__args, **__kw)
  File "pywikibot/login.py", line 115, in __init__
    'wiki_code': self.site.code})
NoUsername: ERROR: Username for wikisource:en is undefined.
If you have an account for that site, please add a line to user-config.py:

usernames['wikisource']['en'] = 'myUsername'

Event Timeline

Seems like setting a dummy username doesnt work. I tried self.site._username = ['Not registered username', None] and got:

======================================================================
ERROR: Test Index page generator on wikisource:en
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ajk/Documents/wiki/pywikibot-core/tests/aspects.py", line 688, in wrapped_method
    func(self, key)
  File "/home/ajk/Documents/wiki/pywikibot-core/tests/proofreadpage_tests.py", line 546, in test_page_gen
    self.assertRaises(ValueError, index_page.page_gen, -1, 2)
  File "/usr/lib/python2.7/unittest/case.py", line 475, in assertRaises
    callableObj(*args, **kwargs)
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/proofreadpage.py", line 613, in page_gen
    % (start, end, 1, self.num_pages))
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/proofreadpage.py", line 471, in wrapper
    self._get_page_mappings()
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/proofreadpage.py", line 514, in _get_page_mappings
    self.purge()
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/page.py", line 1296, in purge
    return self.site.purgepages([self], **kwargs)
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/site.py", line 1300, in callee
    self.login(False)
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/site.py", line 2057, in login
    if loginMan.login(retry=True):
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/login.py", line 265, in login
    self.check_user_exists()
  File "/home/ajk/Documents/wiki/pywikibot-core/pywikibot/login.py", line 140, in check_user_exists
    % (self.username, self.site))
NoUsername: Username 'Not registered username' does not exist on wikisource:en

On further analysis, it seems as though this is not the tests fault.

en.wikisource has changed how it saves the URL we are testing: https://en.wikisource.org/wiki/Index:Popular_Science_Monthly_Volume_1.djvu
Whereas fr and de languages show it in a different way : https://de.wikisource.org/wiki/Index:Musen-Almanach_f%C3%BCr_das_Jahr_1799

The en.wikisource link does not use prp-pagequality now, because of which proofreadpage.py thinks the cached version is corrupt. Even if the username issue was not there, it would have failed with ValueError('Missing class="qualityN prp-pagequality-N" or class="new" in: <pagename>.').

This check happens in proofreadpage.IndexPage._get_page_mappings()

I'm not sure what needs to be done.
Has en.wikisource stopped using the ProofreadPage Extension ? (How do we check this ?)
If yes, do we just remove the en.wikisource test ?
If not, do we mark it to fail and create a new issue to fix the bot ?

This is a strange behavior of en.wikisource, I have not understood what triggers it, there is also a bug to track it. Can't find it now.

If you see no colors on the page, there is not prp-pagequality set.
If then you make a Null Edit (tab on top right of the page), colors will appear, as well as the prp-pagequality tag.

If then you make a Null Edit (tab on top right of the page), colors will appear, as well as the prp-pagequality tag.

Interesting. That does work.

Something I noticed: If I do a Null Edit when I'm not logged in - the colors do not reappear.

@Mpaa the related task you mentioned is here: T114318

@Mpaa the related task you mentioned is here: T114318

Thanks for finding the bug.

Change 327777 had a related patch set uploaded (by Mpaa):
Fix proofreadpage.purge()

https://gerrit.wikimedia.org/r/327777