mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Updates connector tests
This commit is contained in:
parent
232e4bed79
commit
1033d3d045
3 changed files with 8 additions and 7 deletions
|
@ -1,3 +1,3 @@
|
|||
""" settings book data connectors """
|
||||
|
||||
CONNECTORS = ["openlibrary", "inventaire", "self_connector", "bookwyrm_connector"]
|
||||
CONNECTORS = ["openlibrary", "inventaire", "bookwyrm_connector"]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.contrib.auth.models import Group, Permission
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from bookwyrm.models import Connector, FederatedServer, SiteSettings, User
|
||||
from bookwyrm.settings import DOMAIN
|
||||
|
||||
|
||||
def init_groups():
|
||||
|
|
|
@ -50,17 +50,18 @@ class ConnectorManager(TestCase):
|
|||
self.assertIsInstance(connectors[0], BookWyrmConnector)
|
||||
|
||||
@responses.activate
|
||||
def test_search(self):
|
||||
def test_search_plaintext(self):
|
||||
"""search all connectors"""
|
||||
responses.add(
|
||||
responses.GET,
|
||||
"http://fake.ciom/search/Example?min_confidence=0.1",
|
||||
json={},
|
||||
json=[{"title": "Hello", "key": "https://www.example.com/search/1"}],
|
||||
)
|
||||
results = connector_manager.search("Example")
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(len(results[0]["results"]), 1)
|
||||
self.assertEqual(results[0]["results"][0].title, "Example Edition")
|
||||
self.assertEqual(results[0]["connector"].identifier, "test_connector_remote")
|
||||
self.assertEqual(results[0]["results"][0].title, "Hello")
|
||||
|
||||
def test_search_empty_query(self):
|
||||
"""don't panic on empty queries"""
|
||||
|
@ -73,12 +74,13 @@ class ConnectorManager(TestCase):
|
|||
responses.add(
|
||||
responses.GET,
|
||||
"http://fake.ciom/isbn/0000000000",
|
||||
json={},
|
||||
json=[{"title": "Hello", "key": "https://www.example.com/search/1"}],
|
||||
)
|
||||
results = connector_manager.search("0000000000")
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(len(results[0]["results"]), 1)
|
||||
self.assertEqual(results[0]["results"][0].title, "Example Edition")
|
||||
self.assertEqual(results[0]["connector"].identifier, "test_connector_remote")
|
||||
self.assertEqual(results[0]["results"][0].title, "Hello")
|
||||
|
||||
def test_first_search_result(self):
|
||||
"""only get one search result"""
|
||||
|
|
Loading…
Reference in a new issue