tests.api_tests module#
API test module.
- class tests.api_tests.DummyThrottle(site, *, mindelay=None, maxdelay=None, writedelay=None)[source]#
Bases:
Throttle
Dummy Throttle class.
- Parameters:
site (Union[pywikibot.site.BaseSite, str]) –
mindelay (Optional[int]) –
maxdelay (Optional[int]) –
writedelay (Optional[Union[int, float]]) –
- class tests.api_tests.TestApiFunctions(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,DefaultSiteTestCase
API Request object test class.
- abstract_class = False#
- code = 'test'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestCachedRequest(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,DefaultSiteTestCase
Test API Request caching.
This test class does not use the forced test caching.
- abstract_class = False#
- cached = False#
- code = 'test'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestDryApiFunctions(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,DefaultDrySiteTestCase
API Request object test class.
- abstract_class = False#
- code = 'test'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestDryListGenerator(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,TestCase
Test ListGenerator.
- abstract_class = False#
- code = 'en'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.api_tests.TestDryOptionSet(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,DefaultDrySiteTestCase
OptionSet class test class.
- abstract_class = False#
- code = 'test'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestDryPageGenerator(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,TestCase
Dry API PageGenerator object test class.
- abstract_class = False#
- code = 'en'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- titles = ('Broadcaster (definition)', 'Wiktionary', 'Broadcaster.com', 'Wikipedia:Disambiguation')#
- class tests.api_tests.TestDryQueryGeneratorNamespaceParam(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,TestCase
Test setting of namespace param with ListGenerator.
Generators with different characteristics are used. site._paraminfo is not always faithful to API, but serves the purpose here.
- abstract_class = False#
- code = 'en'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.api_tests.TestLagpattern(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,DefaultSiteTestCase
Test the lag pattern.
- abstract_class = False#
- cached = False#
- code = 'test'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestLazyLoginBase(*args, **kwargs)[source]#
Bases:
TestCase
Test that it tries to login when read API access is denied.
Because there is no such family configured it creates an AutoFamily and BaseSite on it’s own. It’s testing against steward.wikimedia.org.
These tests are split into two subclasses as only the first failed login behaves as expected. All subsequent logins will raise an APIError, making it impossible to test two scenarios with the same APISite object.
- abstract_class = True#
- hostname = 'steward.wikimedia.org'#
- class tests.api_tests.TestLazyLoginNoUsername(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestLazyLoginBase
Test no username.
- abstract_class = False#
- net = True#
- sites = {'steward.wikimedia.org': {'hostname': 'steward.wikimedia.org'}}#
- class tests.api_tests.TestLazyLoginNotExistUsername(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestLazyLoginBase
Test missing username.
- abstract_class = False#
- net = True#
- sites = {'steward.wikimedia.org': {'hostname': 'steward.wikimedia.org'}}#
- class tests.api_tests.TestOptionSet(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestCase
OptionSet class test class.
- abstract_class = False#
- code = 'en'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.api_tests.TestOtherSubmodule(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestCase
Test handling multiple different modules having submodules.
- abstract_class = False#
- code = 'mediawiki'#
- family = 'mediawiki'#
- net = True#
- site = True#
- sites = {'mediawiki:mediawiki': {'code': 'mediawiki', 'family': 'mediawiki'}}#
- class tests.api_tests.TestParamInfo(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,DefaultSiteTestCase
Test ParamInfo.
- abstract_class = False#
- code = 'test'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestParaminfoModules(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,DefaultSiteTestCase
Test loading all paraminfo modules.
- abstract_class = False#
- code = 'test'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.api_tests.TestPropertyGenerator(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestCase
API PropertyGenerator object test class.
- abstract_class = False#
- code = 'en'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.api_tests.TestUrlEncoding(*args, **kwargs)[source]#
Bases:
DisableSiteMixin
,TestCase
Test encode_url() function.
- abstract_class = False#