Page MenuHomePhabricator

Travis builds for github forks of pywikibot-core fail with NoUsername error
Closed, ResolvedPublic

Description

https://travis-ci.org/magul/pywikibot-core/jobs/215213345

______ CfdActions.test_strip_cfd_templates_does_nothing_when_no_templates ______

self = <tests.category_bot_tests.CfdActions testMethod=test_strip_cfd_templates_does_nothing_when_no_templates>

    def test_strip_cfd_templates_does_nothing_when_no_templates(self):

        """Test that when there are no CFD templates, the page text is not changed."""

>       bot = CategoryMoveRobot(oldcat='Old', newcat='New')

tests/category_bot_tests.py:23: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

pywikibot/tools/__init__.py:1448: in wrapper

    return obj(*__args, **__kw)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <scripts.category.CategoryMoveRobot object at 0x7f5a1c907f10>

oldcat = 'Old', newcat = 'New', batch = False, comment = '', inplace = False

move_oldcat = True, delete_oldcat = True, title_regex = None, history = False

pagesonly = False, deletion_comment = 0, move_comment = None, wikibase = True

allow_split = False, move_together = False, keep_sortkey = None

    @deprecated_args(oldCatTitle='oldcat', newCatTitle='newcat',

                     batchMode='batch', editSummary='comment',

                     inPlace='inplace', moveCatPage='move_oldcat',

                     deleteEmptySourceCat='delete_oldcat',

                     titleRegex='title_regex', withHistory='history')

    def __init__(self, oldcat, newcat=None, batch=False, comment='',

                 inplace=False, move_oldcat=True, delete_oldcat=True,

                 title_regex=None, history=False, pagesonly=False,

                 deletion_comment=DELETION_COMMENT_AUTOMATIC,

                 move_comment=None,

                 wikibase=True, allow_split=False, move_together=False,

                 keep_sortkey=None):

        """Store all given parameters in the objects attributes.

    

            @param oldcat: The move source.

            @param newcat: The move target.

            @param batch: If True the user has not to confirm the deletion.

            @param comment: The edit summary for all pages where the category is

                changed, and also for moves and deletions if not overridden.

            @param inplace: If True the categories are not reordered.

            @param move_oldcat: If True the category page (and talkpage) is

                copied to the new category.

            @param delete_oldcat: If True the oldcat page and talkpage are

                deleted (or nominated for deletion) if it is empty.

            @param title_regex: Only pages (and subcats) with a title that

                matches the regex are moved.

            @param history: If True the history of the oldcat is posted on

                the talkpage of newcat.

            @param pagesonly: If True only move pages, not subcategories.

            @param deletion_comment: Either string or special value:

                DELETION_COMMENT_AUTOMATIC: use a generated message,

                DELETION_COMMENT_SAME_AS_EDIT_COMMENT: use the same message for

                delete that is used for the edit summary of the pages whose

                category was changed (see the comment param above). If the value

                is not recognized, it's interpreted as DELETION_COMMENT_AUTOMATIC.

            @param move_comment: If set, uses this as the edit summary on the

                actual move of the category page. Otherwise, defaults to the value

                of the comment parameter.

            @param wikibase: If True, update the Wikibase item of the

                old category.

            @param allow_split: If False only moves page and talk page together.

            @param move_together: If True moves the pages/subcategories only if

                page and talk page could be moved or both source page and target

                page don't exist.

            """

        self.site = pywikibot.Site()

        self.can_move_cats = ('move-categorypages' in self.site.userinfo['rights'])

        # Create attributes for the categories and their talk pages.

        self.oldcat = self._makecat(oldcat)

        self.oldtalk = self.oldcat.toggleTalkPage()

        if newcat:

            self.newcat = self._makecat(newcat)

            self.newtalk = self.newcat.toggleTalkPage()

        else:

            self.newcat = None

            self.newtalk = None

        # Set boolean settings.

        self.inplace = inplace

        self.move_oldcat = move_oldcat

        self.delete_oldcat = delete_oldcat

        self.batch = batch

        self.title_regex = title_regex

        self.history = history

        self.pagesonly = pagesonly

        # if that page doesn't has a wikibase

        self.wikibase = wikibase and self.site.has_data_repository

        self.allow_split = allow_split

        self.move_together = move_together

        self.keep_sortkey = keep_sortkey

    

        if not self.can_move_cats:

            repo = self.site.data_repository()

            if self.wikibase and repo.username() is None:

                # The bot can't move categories nor update the Wikibase repo

                raise pywikibot.NoUsername(u"The 'wikibase' option is turned on"

                                           u" and %s has no registered username."

>                                          % repo)

E               NoUsername: The 'wikibase' option is turned on and wikidata:wikidata has no registered username.

Two other tests also fail with the same error:

  • test_strip_cfd_templates_with_spaces_in_comments
  • test_strip_cfd_templates_without_spaces_in_comments

They are all from category_bot_tests.py.

These tests should be fixed if possible, otherwise, according to tests/README.rst, they should be skipped:

All tests which require a logged in user are skipped if the travis-ci build environment does not have a password.

Event Timeline

Adding environment variables PYWIKIBOT2_USERNAME and USER_PASSWORD as per the instructions in the README file resolves the issue. But still the test should be skipped if they are not set.

Change 345373 had a related patch set uploaded (by Dalba):
[pywikibot/core@master] category_bot_tests: Temporarily set a fake username for BaseSite

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

Change 345373 merged by jenkins-bot:
[pywikibot/core@master] category_bot_tests: Temporarily set a fake username for BaseSite

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