Dalba added a comment.

Change 485484 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [tests] Fix some api_tests for wikia

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

This patch is targetting the following failures:

'dbrepllag' is not in siteinfo:

_____________________ TestLagpattern.test_valid_lagpattern _____________________

self = <tests.api_tests.TestLagpattern testMethod=test_valid_lagpattern>

    def test_valid_lagpattern(self):
        """Test whether api.lagpattern is valid."""
        mysite = self.get_site()
>       if mysite.siteinfo['dbrepllag'][0]['lag'] == -1:

tests/api_tests.py:1132: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pywikibot/site.py:1651: in __getitem__
    return self.get(key, False)  # caches and doesn't force it
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pywikibot.site.Siteinfo object at 0x7f9de71818d0>, key = 'dbrepllag'
get_default = False, cache = True, expiry = False

    def get(self, key, get_default=True, cache=True, expiry=False):
        """
        Return a siteinfo property.
    
        It will never throw an APIError if it only stated, that the siteinfo
        property doesn't exist. Instead it will use the default value.
    
        @param key: The name of the siteinfo property.
        @type key: str
        @param get_default: Whether to throw an KeyError if the key is invalid.
        @type get_default: bool
        @param cache: Caches the result interally so that future accesses via
            this method won't query the server.
        @type cache: bool
        @param expiry: If the cache is older than the expiry it ignores the
            cache and queries the server to get the newest value.
        @type expiry: int/float (days), L{datetime.timedelta}, False (never)
        @return: The gathered property
        @rtype: various
        @raises KeyError: If the key is not a valid siteinfo property and the
            get_default option is set to False.
        @see: L{_get_siteinfo}
        """
        # expire = 0 (or timedelta(0)) are always expired and their bool is
        # False, so skip them EXCEPT if it's literally False, then they expire
        # never: "expiry is False" is different than "not expiry"!
        # if it's a int convert to timedelta
        if expiry is not False and isinstance(expiry, (int, float)):
            expiry = datetime.timedelta(expiry)
        if expiry or expiry is False:
            try:
                cached = self._get_cached(key)
            except KeyError:
                pass
            else:  # cached value available
                # is a default value, but isn't accepted
                if not cached[1] and not get_default:
                    raise KeyError(key)
                elif not Siteinfo._is_expired(cached[1], expiry):
                    return copy.deepcopy(cached[0])
        preloaded = self._get_general(key, expiry)
        if not preloaded:
            preloaded = self._get_siteinfo(key, expiry)[key]
        else:
            cache = False
        if not preloaded[1] and not get_default:
>           raise KeyError(key)
E           KeyError: u'dbrepllag'

API warning mismatches:

________________________ TestParamInfo.test_submodules _________________________

self = <tests.api_tests.TestParamInfo testMethod=test_submodules>

    def test_submodules(self):
        """Test another module apart from query having submodules."""
        pi = api.ParamInfo(self.site)
        self.assertFalse(pi._modules)
        pi.fetch(['query'])
        self.assertIn('query', pi._modules)
        self.assertIsInstance(pi._modules['query'], frozenset)
        self.assertIn('revisions', pi._modules['query'])
        self.assertEqual(pi.submodules('query'), pi.query_modules)
        for mod in pi.submodules('query', True):
            self.assertEqual(mod[:6], 'query+')
            self.assertEqual(mod[6:], pi[mod]['name'])
            self.assertEqual(mod, pi[mod]['path'])
    
        with patch.object(pywikibot, 'warning') as w:
            self.assertRaises(KeyError, pi.__getitem__, 'query+foobar')
        # The warning message does not end with a '.' in older MW versions.
        self.assertIn(
            'API warning (paraminfo): '
            'The module "query" does not have a submodule "foobar"',
>           w.call_args[0][0])
E       AssertionError: u'API warning (paraminfo): The module "query" does not have a submodule "foobar"' not found in u"API warning (paraminfo): Unrecognized value for parameter 'querymodules': foobar"

tests/api_tests.py:396: AssertionError
____________________ TestParamInfo.test_with_invalid_module ____________________

self = <tests.api_tests.TestParamInfo testMethod=test_with_invalid_module>

    def test_with_invalid_module(self):
        """Test requesting different kind of invalid modules."""
        site = self.get_site()
        pi = api.ParamInfo(site)
        self.assertEqual(len(pi), 0)
    
        with patch.object(pywikibot, 'warning') as w:
            pi.fetch('foobar')
            self.assertRaises(KeyError, pi.__getitem__, 'foobar')
            self.assertRaises(KeyError, pi.__getitem__, 'foobar+foobar')
        # The warning message does not end with a '.' in older MW versions.
        self.assertIn(
            'API warning (paraminfo): '
            'The module "main" does not have a submodule "foobar"',
>           w.call_args[0][0])
E       AssertionError: u'API warning (paraminfo): The module "main" does not have a submodule "foobar"' not found in u"API warning (paraminfo): Unrecognized value for parameter 'modules': foobar+foobar"

TASK DETAIL
https://phabricator.wikimedia.org/T214009

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt, Dalba
Cc: gerritbot, Aklapper, Dalba, Xqt, pywikibot-bugs-list, CucyNoiD, NebulousIris, Wenyi, Gaboe420, Versusxo, Majesticalreaper22, Giuliamocci, Mahveotm, Adrian1985, Cpaulf30, Baloch007, Darkminds3113, Bsandipan, Lordiis, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to