Page MenuHomePhabricator

TestProofreadPageValidSite.test_json_format is failing
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot/jobs/432052501#L3674

=================================== FAILURES ===================================
_________________ TestProofreadPageValidSite.test_json_format __________________
self = <tests.proofreadpage_tests.TestProofreadPageValidSite testMethod=test_json_format>
    def test_json_format(self):
        """Test conversion to json format."""
        page = ProofreadPage(self.site, self.valid['title'])
    
        rvargs = {'rvprop': 'ids|flags|timestamp|user|comment|content',
                  'rvcontentformat': 'application/json',
                  'titles': page,
                  }
    
        rvgen = self.site._generator(api.PropertyGenerator,
                                     type_arg='info|revisions',
                                     total=1, **rvargs)
        rvgen.set_maximum_items(-1)  # suppress use of rvlimit parameter
    
        try:
>           pagedict = next(iter(rvgen))
tests/proofreadpage_tests.py:278: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pywikibot/data/api.py:3126: in __iter__
    for result in super(PropertyGenerator, self).__iter__():
pywikibot/data/api.py:2950: in __iter__
    self.data = self.request.submit()
pywikibot/data/api.py:2428: in submit
    self._data = super(CachedRequest, self).submit()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = tests.TestRequest<wikisource:en->'/w/api.php?maxlag=5&continue=&format=json&rv...olume+1.djvu/12&meta=userinfo&indexpageids=&rvslots=*&uiprop=blockinfo|hasmsg'>
    def submit(self):
        """
            Submit a query and parse the response.
    
            @return: a dict containing data retrieved from api.php
            @rtype: dict
            """
        self._add_defaults()
        use_get = self._use_get()
    
        while True:
            paramstring = self._http_param_string()
    
            simulate = self._simulate(self.action)
            if simulate:
                return simulate
    
            if self.throttle:
                self.site.throttle(write=self.write)
            else:
                pywikibot.log(
                    "Submitting unthrottled action '{0}'.".format(self.action))
    
            use_get, uri, body, headers = self._get_request_params(use_get,
                                                                   paramstring)
            rawdata, use_get = self._http_request(use_get, uri, body, headers,
                                                  paramstring)
            if rawdata is None:
                continue
    
            result = self._json_loads(rawdata)
            if result is None:
                continue
    
            if self._userinfo_query(result):
                continue
    
            self._handle_warnings(result)
    
            if "error" not in result:
                return result
    
            error = result['error'].copy()
            for key in result:
                if key in ('error', 'warnings'):
                    continue
                assert key not in error
                assert isinstance(result[key], basestring), \
                    'Unexpected %s: %r' % (key, result[key])
                error[key] = result[key]
    
            if "*" in result["error"]:
                # help text returned
                result['error']['help'] = result['error'].pop("*")
            code = result['error'].setdefault('code', 'Unknown')
            info = result['error'].setdefault('info', None)
    
            if not self._logged_in(code):
                continue
    
            if code == "maxlag":
                lag = lagpattern.search(info)
                pywikibot.log('Pausing due to database lag: ' + info)
                if lag:
                    lag = lag.group('lag')
                self.site.throttle.lag(int(lag or 0))
                continue
    
            elif code == 'help' and self.action == 'help':
                # The help module returns an error result with the complete
                # API information. As this data was requested, return the
                # data instead of raising an exception.
                return {'help': {'mime': 'text/plain',
                                 'help': result['error']['help']}}
    
            pywikibot.warning('API error %s: %s' % (code, info))
    
            if self._internal_api_error(code, error, result):
                continue
    
            # Phab. tickets T48535, T64126, T68494, T68619
            if code == "failed-save" and \
               self.action == 'wbeditentity' and \
               self._is_wikibase_error_retryable(result["error"]):
                self.wait()
                continue
    
            # If readapidenied is returned try to login
            if code == 'readapidenied' and self.site._loginstatus in (-3, -1):
                self.site.login()
                continue
    
            if self._bad_token(code):
                continue
    
            if 'mwoauth-invalid-authorization' in code:
                if 'Nonce already used' in info:
                    pywikibot.error(
                        'Retrying failed OAuth authentication for {0}: {1}'
                        .format(self.site, info))
                    continue
                raise NoUsername('Failed OAuth authentication for %s: %s'
                                 % (self.site, info))
            if code == 'cirrussearch-too-busy-error':  # T170647
                self.wait()
                continue
    
            # raise error
            try:
                # Due to bug T66958, Page's repr may return non ASCII bytes
                # Get as bytes in PY2 and decode with the console encoding as
                # the rest should be ASCII anyway.
                param_repr = str(self._params)
                if PY2:
                    param_repr = param_repr.decode(config.console_encoding)
                pywikibot.log(u"API Error: query=\n%s"
                              % pprint.pformat(param_repr))
                pywikibot.log(u"           response=\n%s"
                              % result)
    
>               raise APIError(**result['error'])
E               APIError: invalidparammix: The "rvcontentformat" parameter cannot be used with "rvslots". [help:See https://en.wikisource.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.]
pywikibot/data/api.py:2273: APIError

The failure started after f0eaa4b was merged.

The reason is that rvcontentformat is deprecated and slots don't work with deprecated parameters. We should Update proofreadpage.py to use new parameters.

Event Timeline

Dalba triaged this task as High priority.Sep 23 2018, 6:23 AM

Change 462197 had a related patch set uploaded (by Dalba; owner: dalba):
[pywikibot/core@master] api.QueryGenerator._add_slots: Do not add slots if using deprecated parameters

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

Change 462197 merged by jenkins-bot:
[pywikibot/core@master] api.QueryGenerator._add_slots: Do not add slots if using deprecated parameters

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

Dalba claimed this task.

That's one commit before the patch above.

I've created T205223 for updating proofread.py.