tests.wikibase_tests module#
Tests for the Wikidata parts of the page module.
- class tests.wikibase_tests.TestAlternateNamespaces(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,WikidataTestCase
Test cases to test namespaces of Wikibase entities.
- abstract_class = False#
- cached = False#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestClaim(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test Claim object functionality.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_claim_copy_is_equal()[source]#
Test making a copy of a claim.
The copy of a claim should be always equal to the claim.
- test_claim_copy_is_equal_qualifier()[source]#
Test making a copy of a claim.
The copy of a qualifier should be always equal to the qualifier.
- test_claim_copy_is_equal_source()[source]#
Test making a copy of a claim.
The copy of a source should be always equal to the source.
- test_claim_eq_one_without_qualifiers()[source]#
Test comparing two claims.
If they have the same property and value and one of them has no qualifiers while the other one does, they are not equal.
- test_claim_eq_simple()[source]#
Test comparing two claims.
If they have the same property and value, they are equal.
- test_claim_eq_simple_different_property()[source]#
Test comparing two claims.
If they have the same value and different properties, they are not equal.
- test_claim_eq_simple_different_rank()[source]#
Test comparing two claims.
If they have the same property and value and different ranks, they are equal.
- test_claim_eq_simple_different_snaktype()[source]#
Test comparing two claims.
If they have the same property and different snaktypes, they are not equal.
- test_claim_eq_simple_different_value()[source]#
Test comparing two claims.
If they have the same property and different values, they are not equal.
- test_claim_eq_with_different_qualifiers()[source]#
Test comparing two claims.
If they have the same property and value and different qualifiers, they are not equal.
- test_claim_eq_with_different_sources()[source]#
Test comparing two claims.
If they have the same property and value and different sources, they are equal.
- test_claim_eq_with_qualifiers()[source]#
Test comparing two claims.
If they have the same property, value and qualifiers, they are equal.
- wikibase = True#
- class tests.wikibase_tests.TestClaimSetValue(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test setting claim values.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestGeneral(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
General Wikibase tests.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestItemBasePageMethods(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
,BasePageMethodsTestBase
Test behavior of ItemPage methods inherited from BasePage.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestItemLoad(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test item creation.
Tests for item creation include: 1. by Q id 2. ItemPage.fromPage(page) 3. ItemPage.fromPage(page_with_props_loaded) 4. ItemPage.from_entity_uri(site, uri)
Test various invalid scenarios: 1. invalid Q ids 2. invalid pages to fromPage 3. missing pages to fromPage 4. unconnected pages to fromPage
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'enwiki': {'code': 'en', 'family': 'wikipedia'}, 'wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_empty_item()[source]#
Test empty wikibase item.
should not raise an error as the constructor only requires the site parameter, with the title parameter defaulted to None.
- test_fromPage_missing()[source]#
Test item from deleted page.
A deleted page should not have a wikidata item.
- test_fromPage_noitem()[source]#
Test item from new page.
A new created page should not have a wikidata item yet.
- test_fromPage_redirect()[source]#
Test item from redirect page.
A redirect should not have a wikidata item.
- test_from_entity_uri_invalid_title()[source]#
Test ItemPage.from_entity_uri with an invalid item title format.
- test_from_entity_uri_no_item_lazy()[source]#
Test ItemPage.from_entity_uri with lazy loaded non-existent item.
- test_from_entity_uri_not_a_data_repo()[source]#
Test ItemPage.from_entity_uri with a non-Wikibase site.
- test_item_untrimmed_title()[source]#
Test intrimmed titles of wikibase items.
Spaces in the title should not cause an error.
- test_reuse_item_set_id()[source]#
Test modifying item.id attribute.
Some scripts are using item.id = ‘Q60’ semantics, which does work but modifying item.id does not currently work, and this test highlights that it breaks silently.
- wikibase = True#
- class tests.wikibase_tests.TestItemPageExtensibility(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,TestCase
Test ItemPage extensibility.
- abstract_class = False#
- code = 'en'#
- dry = True#
- family = 'wikipedia'#
- site = True#
- sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
- class tests.wikibase_tests.TestJSON(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test cases to test toJSON() functions.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestLinks(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test cases to test links stored in Wikidata.
Uses a stored data file for the wikibase item. However wikibase creates site objects for each sitelink, and the unit test directly creates a Site for ‘wikipedia:af’ to use in a comparison.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'afwiki': {'code': 'af', 'family': 'wikipedia'}, 'wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestLoadRevisionsCaching(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,BasePageLoadRevisionsCachingTestBase
,WikidataTestCase
Test site.loadrevisions() caching.
- abstract_class = False#
- cached = False#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestLoadUnknownType(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WikidataTestCase
Test unknown datatypes being loaded as WbUnknown.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestNamespaces(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test cases to test namespaces of Wikibase entities.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_empty_wikibase_page()[source]#
Test empty wikibase page.
As a base class it should be able to instantiate it with minimal arguments
- wikibase = True#
- class tests.wikibase_tests.TestOwnClient(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestCase
Test that a data repository family can be its own client.
- abstract_class = False#
- net = True#
- site = True#
- sites = {'wikidata': {'code': 'wikidata', 'family': 'wikidata', 'title': 'Wikidata:Main Page'}, 'wikidatatest': {'code': 'test', 'family': 'wikidata', 'title': 'Page \\[\\[(wikidata\\:)?test\\:Q5296\\]\\] is a redirect page\\.'}}#
- test_own_client_wikidata()#
Test that a data repository family can be its own client on wikidata:wikidata
- test_own_client_wikidatatest()#
Test that a data repository family can be its own client on wikidata:test
- test_page_from_repository_wikidata()#
Test that page_from_repository method works for wikibase too on wikidata:wikidata
- test_page_from_repository_wikidatatest()#
Test that page_from_repository method works for wikibase too on wikidata:test
- class tests.wikibase_tests.TestPageMethodsWithItemTitle(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
,BasePageMethodsTestBase
Test behavior of Page methods for wikibase item.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestPreloadingEntityGenerator(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,TestCase
Test preloading item generator.
- abstract_class = False#
- net = True#
- site = True#
- sites = {'enwiki': {'code': 'en', 'family': 'wikipedia'}, 'wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- class tests.wikibase_tests.TestPropertyPage(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test PropertyPage.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestRedirects(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test redirect and non-redirect items.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestUnconnectedClient(*args, **kwargs)[source]#
Bases:
DisconnectedSiteMixin
,TestCase
Test clients not connected to a data repository.
- abstract_class = False#
- dry = True#
- site = True#
- sites = {'frwikt': {'code': 'fr', 'family': 'wiktionary', 'page_title': 'and'}, 'species': {'code': 'species', 'family': 'species', 'page_title': 'Main Page'}}#
- test_has_data_repository_frwikt()#
Test that site has no data repository on wiktionary:fr
- test_has_data_repository_species()#
Test that site has no data repository on species:species
- test_not_supported_family_frwikt()#
Test that family without a data repository causes error on wiktionary:fr
- test_not_supported_family_species()#
Test that family without a data repository causes error on species:species
- test_page_from_repository_fails_frwikt()#
Test that page_from_repository method fails on wiktionary:fr
- test_page_from_repository_fails_species()#
Test that page_from_repository method fails on species:species
- class tests.wikibase_tests.TestWbGeoShapeNonDry(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WbRepresentationTestCase
Test Wikibase WbGeoShape data type (non-dry).
These require non dry tests due to the page.exists() call.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbGeoShape_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- test_WbGeoShape_error_on_non_exitant_page()[source]#
Test WbGeoShape error handling of a non-existant page.
- test_WbGeoShape_error_on_wrong_page_type()[source]#
Test WbGeoShape error handling of a non-map page.
- test_WbGeoShape_error_on_wrong_site()[source]#
Test WbGeoShape error handling of a page on non-filerepo site.
- wikibase = True#
- class tests.wikibase_tests.TestWbMonolingualText(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WbRepresentationTestCase
Test Wikibase WbMonolingualText data type.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbMonolingualText_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- wikibase = True#
- class tests.wikibase_tests.TestWbQuantity(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WbRepresentationTestCase
Test Wikibase WbQuantity data type.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbQuantity_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- wikibase = True#
- class tests.wikibase_tests.TestWbQuantityNonDry(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WbRepresentationTestCase
Test Wikibase WbQuantity data type (non-dry).
These can be moved to TestWbQuantity once DrySite has been bumped to the appropriate version.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbQuantity_fromWikibase_unbound()[source]#
Test WbQuantity.fromWikibase() instantiating without bounds.
- test_WbQuantity_get_unit_item_different_repo()[source]#
Test getting unit item in different repo from WbQuantity.
- test_WbQuantity_get_unit_item_provide_repo()[source]#
Test getting unit item from WbQuantity, providing repo.
- wikibase = True#
- class tests.wikibase_tests.TestWbTabularDataNonDry(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WbRepresentationTestCase
Test Wikibase WbTabularData data type (non-dry).
These require non dry tests due to the page.exists() call.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbTabularData_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- test_WbTabularData_error_on_non_exitant_page()[source]#
Test WbTabularData error handling of a non-existant page.
- test_WbTabularData_error_on_non_page()[source]#
Test WbTabularData error handling when given a non-page.
- test_WbTabularData_error_on_wrong_page_type()[source]#
Test WbTabularData error handling of a non-map page.
- test_WbTabularData_error_on_wrong_site()[source]#
Test WbTabularData error handling of a page on non-filerepo site.
- wikibase = True#
- class tests.wikibase_tests.TestWbTime(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WbRepresentationTestCase
Test Wikibase WbTime data type.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbTime_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- wikibase = True#
- class tests.wikibase_tests.TestWbUnknown(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WbRepresentationTestCase
Test Wikibase WbUnknown data type.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_WbUnknown_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- wikibase = True#
- class tests.wikibase_tests.TestWikibaseCoordinate(*args, **kwargs)[source]#
Bases:
ForceCacheMixin
,DisconnectedSiteMixin
,WbRepresentationTestCase
Test Wikibase Coordinate data type.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- dry = True#
- family = 'wikidata'#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_Coordinate_WbRepresentation_methods()[source]#
Test inherited or extended methods from _WbRepresentation.
- wikibase = True#
- class tests.wikibase_tests.TestWikibaseCoordinateNonDry(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WbRepresentationTestCase
Test Wikibase Coordinate data type (non-dry).
These can be moved to TestWikibaseCoordinate once DrySite has been bumped to the appropriate version.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- test_Coordinate_get_globe_item_different_repo()[source]#
Test getting globe item in different repo from Coordinate.
- test_Coordinate_get_globe_item_from_itempage()[source]#
Test getting globe item from Coordinate with ItemPage globe.
- test_Coordinate_get_globe_item_from_plain_globe()[source]#
Test getting globe item from Coordinate with plain text globe.
- test_Coordinate_get_globe_item_from_uri()[source]#
Test getting globe item from Coordinate with entity uri globe.
- test_Coordinate_get_globe_item_provide_repo()[source]#
Test getting globe item from Coordinate, providing repo.
- wikibase = True#
- class tests.wikibase_tests.TestWikibaseParser(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin
,ForceCacheMixin
,WikidataTestCase
Test passing various datatypes to wikibase parser.
- abstract_class = False#
- cached = True#
- code = 'wikidata'#
- family = 'wikidata'#
- net = True#
- site = True#
- sites = {'wikidata:wikidata': {'code': 'wikidata', 'family': 'wikidata'}}#
- wikibase = True#
- class tests.wikibase_tests.TestWriteNormalizeData(*args, **kwargs)[source]#
Bases:
DisableSiteMixin
,TestCase
Test cases for routines that normalize data for writing to Wikidata.
Exercises ItemPage._normalizeData with data that is not normalized and data which is already normalized.
- abstract_class = False#
- class tests.wikibase_tests.WbRepresentationTestCase(*args, **kwargs)[source]#
Bases:
WikidataTestCase
Test methods inherited or extended from _WbRepresentation.
- abstract_class = True#