jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/390872 )
Change subject: Use http scheme for Wikidata entity URIs ......................................................................
Use http scheme for Wikidata entity URIs
Wikidata's API currently responds with `http` URIs for entities. This patch reverts Wikidata related parts of cf84e4f616372289239e76fa0ac08896 which were causing some tests to fail.
Bug: T102315 Change-Id: I769dca0bb9e62c2c5695f344d2757ea3ad50f53a --- M pywikibot/families/wikidata_family.py M tests/wikibase_tests.py 2 files changed, 62 insertions(+), 62 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/families/wikidata_family.py b/pywikibot/families/wikidata_family.py index 7e8b47e..f59fb12 100644 --- a/pywikibot/families/wikidata_family.py +++ b/pywikibot/families/wikidata_family.py @@ -54,7 +54,7 @@
def calendarmodel(self, code): """Default calendar model for WbTime datatype.""" - return 'https://www.wikidata.org/entity/Q1985727' + return 'http://www.wikidata.org/entity/Q1985727'
def shared_geo_shape_repository(self, code): """Return Wikimedia Commons as the repository for geo-shapes.""" @@ -73,38 +73,38 @@ def globes(self, code): """Supported globes for Coordinate datatype.""" return { - 'ariel': 'https://www.wikidata.org/entity/Q3343', - 'callisto': 'https://www.wikidata.org/entity/Q3134', - 'ceres': 'https://www.wikidata.org/entity/Q596', - 'deimos': 'https://www.wikidata.org/entity/Q7548', - 'dione': 'https://www.wikidata.org/entity/Q15040', - 'earth': 'https://www.wikidata.org/entity/Q2', - 'enceladus': 'https://www.wikidata.org/entity/Q3303', - 'eros': 'https://www.wikidata.org/entity/Q16711', - 'europa': 'https://www.wikidata.org/entity/Q3143', - 'ganymede': 'https://www.wikidata.org/entity/Q3169', - 'gaspra': 'https://www.wikidata.org/entity/Q158244', - 'hyperion': 'https://www.wikidata.org/entity/Q15037', - 'iapetus': 'https://www.wikidata.org/entity/Q17958', - 'io': 'https://www.wikidata.org/entity/Q3123', - 'jupiter': 'https://www.wikidata.org/entity/Q319', - 'lutetia': 'https://www.wikidata.org/entity/Q107556', - 'mars': 'https://www.wikidata.org/entity/Q111', - 'mercury': 'https://www.wikidata.org/entity/Q308', - 'mimas': 'https://www.wikidata.org/entity/Q15034', - 'miranda': 'https://www.wikidata.org/entity/Q3352', - 'moon': 'https://www.wikidata.org/entity/Q405', - 'oberon': 'https://www.wikidata.org/entity/Q3332', - 'phobos': 'https://www.wikidata.org/entity/Q7547', - 'phoebe': 'https://www.wikidata.org/entity/Q17975', - 'pluto': 'https://www.wikidata.org/entity/Q339', - 'rhea': 'https://www.wikidata.org/entity/Q15050', - 'steins': 'https://www.wikidata.org/entity/Q150249', - 'tethys': 'https://www.wikidata.org/entity/Q15047', - 'titan': 'https://www.wikidata.org/entity/Q2565', - 'titania': 'https://www.wikidata.org/entity/Q3322', - 'triton': 'https://www.wikidata.org/entity/Q3359', - 'umbriel': 'https://www.wikidata.org/entity/Q3338', - 'venus': 'https://www.wikidata.org/entity/Q313', - 'vesta': 'https://www.wikidata.org/entity/Q3030', + 'ariel': 'http://www.wikidata.org/entity/Q3343', + 'callisto': 'http://www.wikidata.org/entity/Q3134', + 'ceres': 'http://www.wikidata.org/entity/Q596', + 'deimos': 'http://www.wikidata.org/entity/Q7548', + 'dione': 'http://www.wikidata.org/entity/Q15040', + 'earth': 'http://www.wikidata.org/entity/Q2', + 'enceladus': 'http://www.wikidata.org/entity/Q3303', + 'eros': 'http://www.wikidata.org/entity/Q16711', + 'europa': 'http://www.wikidata.org/entity/Q3143', + 'ganymede': 'http://www.wikidata.org/entity/Q3169', + 'gaspra': 'http://www.wikidata.org/entity/Q158244', + 'hyperion': 'http://www.wikidata.org/entity/Q15037', + 'iapetus': 'http://www.wikidata.org/entity/Q17958', + 'io': 'http://www.wikidata.org/entity/Q3123', + 'jupiter': 'http://www.wikidata.org/entity/Q319', + 'lutetia': 'http://www.wikidata.org/entity/Q107556', + 'mars': 'http://www.wikidata.org/entity/Q111', + 'mercury': 'http://www.wikidata.org/entity/Q308', + 'mimas': 'http://www.wikidata.org/entity/Q15034', + 'miranda': 'http://www.wikidata.org/entity/Q3352', + 'moon': 'http://www.wikidata.org/entity/Q405', + 'oberon': 'http://www.wikidata.org/entity/Q3332', + 'phobos': 'http://www.wikidata.org/entity/Q7547', + 'phoebe': 'http://www.wikidata.org/entity/Q17975', + 'pluto': 'http://www.wikidata.org/entity/Q339', + 'rhea': 'http://www.wikidata.org/entity/Q15050', + 'steins': 'http://www.wikidata.org/entity/Q150249', + 'tethys': 'http://www.wikidata.org/entity/Q15047', + 'titan': 'http://www.wikidata.org/entity/Q2565', + 'titania': 'http://www.wikidata.org/entity/Q3322', + 'triton': 'http://www.wikidata.org/entity/Q3359', + 'umbriel': 'http://www.wikidata.org/entity/Q3338', + 'venus': 'http://www.wikidata.org/entity/Q313', + 'vesta': 'http://www.wikidata.org/entity/Q3030', } diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index 7cb88ac..a07de41 100644 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -191,18 +191,18 @@ self.assertEqual(coord.toWikibase(), {'latitude': 12.0, 'longitude': 13.0, 'altitude': None, 'precision': 0, - 'globe': 'https://www.wikidata.org/entity/Q405%27%7D) + 'globe': 'http://www.wikidata.org/entity/Q405%27%7D)
def test_Coordinate_entity_uri_globe(self): """Test setting Coordinate globe from an entity uri.""" repo = self.get_repo() coord = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0, - globe_item='https://www.wikidata.org/entity/Q123') + globe_item='http://www.wikidata.org/entity/Q123') self.assertEqual(coord.toWikibase(), {'latitude': 12.0, 'longitude': 13.0, 'altitude': None, 'precision': 0, - 'globe': 'https://www.wikidata.org/entity/Q123%27%7D) + 'globe': 'http://www.wikidata.org/entity/Q123%27%7D)
class TestWikibaseCoordinateNonDry(WbRepresentationTestCase): @@ -223,14 +223,14 @@ self.assertEqual(coord.toWikibase(), {'latitude': 12.0, 'longitude': 13.0, 'altitude': None, 'precision': 0, - 'globe': 'https://www.wikidata.org/entity/Q123%27%7D) + 'globe': 'http://www.wikidata.org/entity/Q123%27%7D)
def test_Coordinate_get_globe_item_from_uri(self): """Test getting globe item from Coordinate with entity uri globe.""" repo = self.get_repo() q = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0, - globe_item='https://www.wikidata.org/entity/Q123') + globe_item='http://www.wikidata.org/entity/Q123') self.assertEqual(q.get_globe_item(), ItemPage(repo, 'Q123'))
def test_Coordinate_get_globe_item_from_itempage(self): @@ -253,7 +253,7 @@ repo = self.get_repo() q = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0, - globe_item='https://www.wikidata.org/entity/Q123') + globe_item='http://www.wikidata.org/entity/Q123') self.assertEqual(q.get_globe_item(repo), ItemPage(repo, 'Q123'))
def test_Coordinate_get_globe_item_different_repo(self): @@ -262,7 +262,7 @@ test_repo = pywikibot.Site('test', 'wikidata') q = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0, - globe_item='https://test.wikidata.org/entity/Q123') + globe_item='http://test.wikidata.org/entity/Q123') self.assertEqual(q.get_globe_item(test_repo), ItemPage(test_repo, 'Q123'))
@@ -274,13 +274,13 @@ globe='moon') b = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0.1, - globe_item='https://www.wikidata.org/entity/Q405') + globe_item='http://www.wikidata.org/entity/Q405') c = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0.1, globe_item=ItemPage(repo, 'Q405')) d = pywikibot.Coordinate( site=repo, lat=12.0, lon=13.0, precision=0.1, - globe_item='https://test.wikidata.org/entity/Q405') + globe_item='http://test.wikidata.org/entity/Q405') self.assertEqual(a, b) self.assertEqual(b, c) self.assertEqual(c, a) @@ -478,23 +478,23 @@ """Test WbQuantity with entity uri unit.""" repo = self.get_repo() q = pywikibot.WbQuantity(amount=1234, error=1, site=repo, - unit='https://www.wikidata.org/entity/Q712226') + unit='http://www.wikidata.org/entity/Q712226') self.assertEqual(q.toWikibase(), {'amount': '+1234', 'lowerBound': '+1233', 'upperBound': '+1235', - 'unit': 'https://www.wikidata.org/entity/Q712226', }) + 'unit': 'http://www.wikidata.org/entity/Q712226', })
def test_WbQuantity_unit_fromWikibase(self): """Test WbQuantity recognising unit from Wikibase output.""" repo = self.get_repo() q = pywikibot.WbQuantity.fromWikibase({ 'amount': '+1234', 'lowerBound': '+1233', 'upperBound': '+1235', - 'unit': 'https://www.wikidata.org/entity/Q712226', }, + 'unit': 'http://www.wikidata.org/entity/Q712226', }, site=repo) self.assertEqual(q.toWikibase(), {'amount': '+1234', 'lowerBound': '+1233', 'upperBound': '+1235', - 'unit': 'https://www.wikidata.org/entity/Q712226', }) + 'unit': 'http://www.wikidata.org/entity/Q712226', })
class TestWbQuantityNonDry(WbRepresentationTestCase): @@ -563,7 +563,7 @@ self.assertEqual(q.toWikibase(), {'amount': '+1234', 'lowerBound': '+1233', 'upperBound': '+1235', - 'unit': 'https://www.wikidata.org/entity/Q712226', }) + 'unit': 'http://www.wikidata.org/entity/Q712226', })
def test_WbQuantity_equality(self): """Test WbQuantity equality with different unit representations.""" @@ -576,13 +576,13 @@ unit=pywikibot.ItemPage(self.repo, 'Q712226')) b = pywikibot.WbQuantity( amount=1234, error=1, - unit='https://www.wikidata.org/entity/Q712226') + unit='http://www.wikidata.org/entity/Q712226') c = pywikibot.WbQuantity( amount=1234, error=1, - unit='https://test.wikidata.org/entity/Q712226') + unit='http://test.wikidata.org/entity/Q712226') d = pywikibot.WbQuantity( amount=1234, error=2, - unit='https://www.wikidata.org/entity/Q712226') + unit='http://www.wikidata.org/entity/Q712226') self.assertEqual(a, b) self.assertNotEqual(a, c) self.assertNotEqual(b, c) @@ -592,7 +592,7 @@ """Test getting unit item from WbQuantity.""" repo = self.get_repo() q = pywikibot.WbQuantity(amount=1234, error=1, site=repo, - unit='https://www.wikidata.org/entity/Q123') + unit='http://www.wikidata.org/entity/Q123') self.assertEqual(q.get_unit_item(), ItemPage(repo, 'Q123'))
@@ -600,7 +600,7 @@ """Test getting unit item from WbQuantity, providing repo.""" repo = self.get_repo() q = pywikibot.WbQuantity(amount=1234, error=1, - unit='https://www.wikidata.org/entity/Q123') + unit='http://www.wikidata.org/entity/Q123') self.assertEqual(q.get_unit_item(repo), ItemPage(repo, 'Q123'))
@@ -609,7 +609,7 @@ repo = self.get_repo() test_repo = pywikibot.Site('test', 'wikidata') q = pywikibot.WbQuantity(amount=1234, error=1, site=repo, - unit='https://test.wikidata.org/entity/Q123') + unit='http://test.wikidata.org/entity/Q123') self.assertEqual(q.get_unit_item(test_repo), ItemPage(test_repo, 'Q123'))
@@ -1224,42 +1224,42 @@ def test_from_entity_uri(self): """Test ItemPage.from_entity_uri.""" repo = self.get_repo() - entity_uri = 'https://www.wikidata.org/entity/Q124' + entity_uri = 'http://www.wikidata.org/entity/Q124' self.assertEqual(ItemPage.from_entity_uri(repo, entity_uri), ItemPage(repo, 'Q124'))
def test_from_entity_uri_not_a_data_repo(self): """Test ItemPage.from_entity_uri with a non-Wikibase site.""" repo = self.site - entity_uri = 'https://www.wikidata.org/entity/Q124' + entity_uri = 'http://www.wikidata.org/entity/Q124' self.assertRaises(TypeError, ItemPage.from_entity_uri, repo, entity_uri)
def test_from_entity_uri_wrong_repo(self): """Test ItemPage.from_entity_uri with unexpected item repo.""" repo = self.get_repo() - entity_uri = 'https://test.wikidata.org/entity/Q124' + entity_uri = 'http://test.wikidata.org/entity/Q124' self.assertRaises(ValueError, ItemPage.from_entity_uri, repo, entity_uri)
def test_from_entity_uri_invalid_title(self): """Test ItemPage.from_entity_uri with an invalid item title format.""" repo = self.get_repo() - entity_uri = 'https://www.wikidata.org/entity/Nonsense' + entity_uri = 'http://www.wikidata.org/entity/Nonsense' self.assertRaises(pywikibot.InvalidTitle, ItemPage.from_entity_uri, repo, entity_uri)
def test_from_entity_uri_no_item(self): """Test ItemPage.from_entity_uri with non-exitent item.""" repo = self.get_repo() - entity_uri = 'https://www.wikidata.org/entity/Q999999999999999999' + entity_uri = 'http://www.wikidata.org/entity/Q999999999999999999' self.assertRaises(pywikibot.NoPage, ItemPage.from_entity_uri, repo, entity_uri)
def test_from_entity_uri_no_item_lazy(self): """Test ItemPage.from_entity_uri with lazy loaded non-exitent item.""" repo = self.get_repo() - entity_uri = 'https://www.wikidata.org/entity/Q999999999999999999' + entity_uri = 'http://www.wikidata.org/entity/Q999999999999999999' expected_item = ItemPage(repo, 'Q999999999999999999') self.assertEqual( ItemPage.from_entity_uri(repo, entity_uri, lazy_load=True), @@ -1382,7 +1382,7 @@ claim = pywikibot.Claim(wikidata, 'P1106') self.assertEqual(claim.type, 'quantity') target = pywikibot.WbQuantity( - amount=1234, error=1, unit='https://www.wikidata.org/entity/Q11573') + amount=1234, error=1, unit='http://www.wikidata.org/entity/Q11573') claim.setTarget(target) self.assertEqual(claim.target, target)
pywikibot-commits@lists.wikimedia.org