def test_get_connectors(self): """ load all connectors """ remote_id = "https://example.com/object/1" connector_manager.get_or_create_connector(remote_id) connectors = list(connector_manager.get_connectors()) self.assertEqual(len(connectors), 2) self.assertIsInstance(connectors[0], SelfConnector) self.assertIsInstance(connectors[1], BookWyrmConnector)
def test_get_or_create_connector(self): """loads a connector if the data source is known or creates one""" remote_id = "https://example.com/object/1" connector = connector_manager.get_or_create_connector(remote_id) self.assertIsInstance(connector, BookWyrmConnector) self.assertEqual(connector.identifier, "example.com") self.assertEqual(connector.base_url, "https://example.com") same_connector = connector_manager.get_or_create_connector(remote_id) self.assertEqual(connector.identifier, same_connector.identifier)
def resolve_book(request): """ figure out the local path to a book from a remote_id """ remote_id = request.POST.get("remote_id") connector = connector_manager.get_or_create_connector(remote_id) book = connector.get_or_create_book(remote_id) return redirect("/book/%d" % book.id)
def resolve_book(request): ''' figure out the local path to a book from a remote_id ''' remote_id = request.POST.get('remote_id') connector = connector_manager.get_or_create_connector(remote_id) book = connector.get_or_create_book(remote_id) return redirect('/book/%d' % book.id)