jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1179641?usp=email )
Change subject: Fix wikibase_tests
......................................................................
Fix wikibase_tests
label for Q60 was removed and tests can use the default 'mul'
- Updated wikibase tests using 'mul' instead of 'en' labels
- Add test_base_data to test 'en' labels and aliases with
local json file
- Add test_normalized_invalid_data test to test TypeError for
unsupported value type in ItemPage._normalizeData method
- Add BaseDataDict to Sphinx documentation
Bug: T402084
Change-Id: I8640e1e79f7ddac5e3fd12e307b6691c51a2a9cf
---
M docs/api_ref/pywikibot.page.rst
M tests/wikibase_tests.py
2 files changed, 22 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
Matěj Suchánek: Looks good to me, approved
diff --git a/docs/api_ref/pywikibot.page.rst b/docs/api_ref/pywikibot.page.rst
index 7d38815..0ea0b77 100644
--- a/docs/api_ref/pywikibot.page.rst
+++ b/docs/api_ref/pywikibot.page.rst
@@ -32,6 +32,8 @@
.. automodule:: pywikibot.page._collections
:synopsis: Structures holding data for Wikibase entities
+.. autoclass:: BaseDataDict
+
:mod:`page.\_decorators` --- Page Decorators
============================================
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index eb8c7df..14ef333 100755
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -283,9 +283,9 @@
self.assertNotHasAttr(item, '_content')
item.get()
self.assertHasAttr(item, '_content')
- self.assertIn('en', item.labels)
+ self.assertIn('mul', item.labels)
# label could change
- self.assertIn(item.labels['en'], ['New York', 'New York City'])
+ self.assertIn(item.labels['mul'], ['New York', 'New York City'])
self.assertEqual(item.title(), 'Q60')
def test_reuse_item_set_id(self) -> None:
@@ -300,7 +300,7 @@
wikidata = self.get_repo()
item = ItemPage(wikidata, 'Q60')
item.get()
- self.assertIn(item.labels['en'], label)
+ self.assertIn(item.labels['mul'], label)
# When the id attribute is modified, the ItemPage goes into
# an inconsistent state.
@@ -312,7 +312,7 @@
# it doesn't help to clear this piece of saved state.
del item._content
# The labels are not updated; assertion showing undesirable behaviour:
- self.assertIn(item.labels['en'], label)
+ self.assertIn(item.labels['mul'], label)
def test_empty_item(self) -> None:
"""Test empty wikibase item.
@@ -1127,6 +1127,14 @@
copy.deepcopy(self.data_out))
self.assertEqual(response, self.data_out)
+ def test_normalized_invalid_data(self) -> None:
+ """Test _normalizeData() method for invalid data."""
+ data = copy.deepcopy(self.data_out)
+ data['aliases']['en'] = tuple(data['aliases']['en'])
+ with self.assertRaisesRegex(TypeError,
+ "Unsupported value type 'tuple'"):
+ ItemPage._normalizeData(data)
+
class TestPreloadingEntityGenerator(TestCase):
@@ -1437,6 +1445,14 @@
del self.wdp._content['lastrevid']
del self.wdp._content['pageid']
+ def test_base_data(self) -> None:
+ """Test labels and aliases collections."""
+ item = self.wdp
+ self.assertIn('en', item.labels)
+ self.assertEqual(item.labels['en'], 'New York City')
+ self.assertIn('en', item.aliases)
+ self.assertIn('NYC', item.aliases['en'])
+
def test_itempage_json(self) -> None:
"""Test itempage json."""
old = json.dumps(self.wdp._content, indent=2, sort_keys=True)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1179641?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I8640e1e79f7ddac5e3fd12e307b6691c51a2a9cf
Gerrit-Change-Number: 1179641
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]