Skip to content

Commit

Permalink
Merge "Add title function to MediaInfo."
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Sep 8, 2024
2 parents fb6351b + 161ad71 commit 7c36718
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pywikibot/page/_wikibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ def getID(self, numeric: bool = False):
self._assert_has_id()
return super().getID(numeric=numeric)

def title(self):
"""
Return ID as title of the MediaInfo.
:return: str: the entity identifier
"""
return self.getID()

def editLabels(self, labels: LANGUAGE_TYPE, **kwargs) -> None:
"""Edit MediaInfo labels (eg. captions).
Expand Down
3 changes: 3 additions & 0 deletions tests/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def test_data_item(self):
self.assertEqual('-1', item.id)
item.get()
self.assertEqual('M14634781', item.id)
self.assertEqual('M14634781', item.title())
self.assertIsInstance(
item.labels, pywikibot.page._collections.LanguageDict)
self.assertIsInstance(
Expand Down Expand Up @@ -400,6 +401,8 @@ def test_data_item_when_no_file_or_data_item(self):

with self.assertRaises(NoWikibaseEntityError):
item.get()
with self.assertRaises(NoWikibaseEntityError):
item.title()
with self.assertRaises(NoWikibaseEntityError):
item.labels

Expand Down

0 comments on commit 7c36718

Please sign in to comment.