Exemplo n.º 1
0
    def test_init_pageset(self):
        """Test initializing with only the pageset."""
        site = self.get_site()
        self.assertNotIn('query', api.ParamInfo.init_modules)
        pi = api.ParamInfo(site, {'pageset'})
        self.assertNotIn('query', api.ParamInfo.init_modules)
        self.assertEqual(len(pi), 0)
        pi._init()

        self.assertIn('main', pi._paraminfo)
        self.assertIn('paraminfo', pi._paraminfo)
        self.assertIn('pageset', pi._paraminfo)

        if MediaWikiVersion(self.site.version()) < MediaWikiVersion("1.12"):
            return

        if 'query' in pi.preloaded_modules:
            self.assertIn('query', pi._paraminfo)
            self.assertEqual(len(pi), 4)
        else:
            self.assertNotIn('query', pi._paraminfo)
            self.assertEqual(len(pi), 3)

        self.assertEqual(len(pi), len(pi.preloaded_modules))

        if MediaWikiVersion(site.version()) >= MediaWikiVersion("1.21"):
            # 'generator' was added to 'pageset' in 1.21
            generators_param = pi.parameter('pageset', 'generator')
            self.assertGreater(len(generators_param['type']), 1)
Exemplo n.º 2
0
    def test_init_pageset(self):
        site = self.get_site()
        self.assertNotIn('query', api.ParamInfo.init_modules)
        pi = api.ParamInfo(site, set(['pageset']))
        self.assertNotIn('query', api.ParamInfo.init_modules)
        self.assertEqual(len(pi), 0)
        pi._init()

        self.assertIn('main', pi._paraminfo)
        self.assertIn('paraminfo', pi._paraminfo)
        self.assertIn('pageset', pi._paraminfo)

        if MediaWikiVersion(self.site.version()) < MediaWikiVersion("1.12"):
            return

        if 'query' in pi.preloaded_modules:
            self.assertIn('query', pi._paraminfo)
            self.assertEqual(len(pi), 4)
        else:
            self.assertNotIn('query', pi._paraminfo)
            self.assertEqual(len(pi), 3)

        self.assertEqual(len(pi),
                         len(pi.preloaded_modules))

        if MediaWikiVersion(site.version()) >= MediaWikiVersion("1.21"):
            # 'generator' was added to 'pageset' in 1.21
            generators_param = pi.parameter('pageset', 'generator')
            self.assertGreater(len(generators_param['type']), 1)
Exemplo n.º 3
0
    def test_new_mode(self):
        site = self.get_site()
        if MediaWikiVersion(site.version()) < MediaWikiVersion('1.25wmf4'):
            raise unittest.SkipTest(
                "version %s doesn't support the new paraminfo api" %
                site.version())
        pi = api.ParamInfo(site, modules_only_mode=True)
        pi.fetch(['info'])
        self.assertIn('query+info', pi._paraminfo)

        self.assertIn('main', pi._paraminfo)
        self.assertIn('paraminfo', pi._paraminfo)

        self.assertEqual(len(pi), 1 + len(pi.preloaded_modules))

        self.assertIn('revisions', pi.prefixes)
Exemplo n.º 4
0
    def test_new_mode(self):
        site = self.get_site()
        if MediaWikiVersion(site.version()) < MediaWikiVersion('1.25wmf4'):
            raise unittest.SkipTest(
                "version %s doesn't support the new paraminfo api"
                % site.version())
        pi = api.ParamInfo(site, modules_only_mode=True)
        pi.fetch(['info'])
        self.assertIn('query+info', pi._paraminfo)

        self.assertIn('main', pi._paraminfo)
        self.assertIn('paraminfo', pi._paraminfo)

        self.assertEqual(len(pi),
                         1 + len(pi.preloaded_modules))

        self.assertIn('revisions', pi.prefixes)
Exemplo n.º 5
0
    def test_generators(self):
        site = self.get_site()
        pi = api.ParamInfo(site, set(['pageset', 'query']))
        self.assertEqual(len(pi), 0)
        pi._init()

        self.assertIn('main', pi._paraminfo)
        self.assertIn('paraminfo', pi._paraminfo)
        self.assertIn('pageset', pi._paraminfo)
        self.assertIn('query', pi._paraminfo)

        if MediaWikiVersion(site.version()) >= MediaWikiVersion("1.21"):
            # 'generator' was added to 'pageset' in 1.21
            pageset_generators_param = pi.parameter('pageset', 'generator')
            query_generators_param = pi.parameter('query', 'generator')

            self.assertEqual(pageset_generators_param, query_generators_param)