jenkins-bot has submitted this change and it was merged.
Change subject: Add support for identifier data type ......................................................................
Add support for identifier data type
No tests could be added to wikibase_tests.py since the data type is not yet active on wikidata.
No tests added to edit_failiure_tests.py since there is no additional string validation.
Bug: T123882 Change-Id: I7fd4f5f4bba8a4eb2f83b8b093eb2faf2e64f811 --- M pywikibot/page.py M tests/wikibase_edit_tests.py 2 files changed, 19 insertions(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 244c300..0349676 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4080,6 +4080,7 @@ 'quantity': pywikibot.WbQuantity, 'monolingualtext': pywikibot.WbMonolingualText, 'math': basestring, + 'external-id': basestring, }
value_types = {'wikibase-item': 'wikibase-entityid', @@ -4087,6 +4088,7 @@ 'url': 'string', 'globe-coordinate': 'globecoordinate', 'math': 'string', + 'external-id': 'string', }
def __init__(self, site, id=None, datatype=None): @@ -4628,7 +4630,7 @@ if self.type == 'wikibase-item': value = {'entity-type': 'item', 'numeric-id': self.getTarget().getID(numeric=True)} - elif self.type in ('string', 'url', 'math'): + elif self.type in ('string', 'url', 'math', 'external-id'): value = self.getTarget() elif self.type == 'commonsMedia': value = self.getTarget().title(withNamespace=False) diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py index 18f74a4..2f984df 100644 --- a/tests/wikibase_edit_tests.py +++ b/tests/wikibase_edit_tests.py @@ -238,6 +238,22 @@ claim = item.claims['P271'][0] self.assertEqual(claim.getTarget(), target)
+ def test_identifier_edit(self): + """Attempt adding a math claim with valid input.""" + testsite = self.get_repo() + item = self._clean_item(testsite, 'P718') + + # set new claim + claim = pywikibot.page.Claim(testsite, 'P718', datatype='external-id') + target = 'CrazyURI123_:)' + claim.setTarget(target) + item.addClaim(claim) + + # confirm new claim + item.get(force=True) + claim = item.claims['P718'][0] + self.assertEqual(claim.getTarget(), target) +
class TestWikibaseRemoveQualifier(WikibaseTestCase):
pywikibot-commits@lists.wikimedia.org