Merge pull request #3492 from bookwyrm-social/inventaire-titles

Alters get_description code for inventaire queries
This commit is contained in:
Mouse Reeve 2025-01-10 18:21:17 -08:00 committed by GitHub
commit 03bab92ee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -222,9 +222,10 @@ class Connector(AbstractConnector):
def get_description(self, links: JsonDict) -> str:
"""grab an extracted excerpt from wikipedia"""
link = links.get("enwiki")
if not link:
if not link or not link.get("title"):
return ""
url = f"{self.base_url}/api/data?action=wp-extract&lang=en&title={link}"
title = link.get("title")
url = f"{self.base_url}/api/data?action=wp-extract&lang=en&title={title}"
try:
data = get_data(url)
except ConnectorException:

View file

@ -273,7 +273,9 @@ class Inventaire(TestCase):
json={"extract": "hi hi"},
)
extract = self.connector.get_description({"enwiki": "test_path"})
extract = self.connector.get_description(
{"enwiki": {"title": "test_path", "badges": "hello"}}
)
self.assertEqual(extract, "hi hi")
def test_remote_id_from_model(self):