More tests for bookwyrm connector
This commit is contained in:
parent
382170d662
commit
6b22de2075
|
@ -23,10 +23,12 @@ class BookWyrmConnector(TestCase):
|
||||||
)
|
)
|
||||||
self.connector = Connector("example.com")
|
self.connector = Connector("example.com")
|
||||||
|
|
||||||
work_file = pathlib.Path(__file__).parent.joinpath("../data/bw_work.json")
|
def test_get_or_create_book_existing(self):
|
||||||
edition_file = pathlib.Path(__file__).parent.joinpath("../data/bw_edition.json")
|
""" load book activity """
|
||||||
self.work_data = json.loads(work_file.read_bytes())
|
work = models.Work.objects.create(title="Test Work")
|
||||||
self.edition_data = json.loads(edition_file.read_bytes())
|
book = models.Edition.objects.create(title="Test Edition", parent_work=work)
|
||||||
|
result = self.connector.get_or_create_book(book.remote_id)
|
||||||
|
self.assertEqual(book, result)
|
||||||
|
|
||||||
def test_format_search_result(self):
|
def test_format_search_result(self):
|
||||||
""" create a SearchResult object from search response json """
|
""" create a SearchResult object from search response json """
|
||||||
|
@ -42,3 +44,11 @@ class BookWyrmConnector(TestCase):
|
||||||
self.assertEqual(result.author, "Susanna Clarke")
|
self.assertEqual(result.author, "Susanna Clarke")
|
||||||
self.assertEqual(result.year, 2017)
|
self.assertEqual(result.year, 2017)
|
||||||
self.assertEqual(result.connector, self.connector)
|
self.assertEqual(result.connector, self.connector)
|
||||||
|
|
||||||
|
def test_format_isbn_search_result(self):
|
||||||
|
""" just gotta attach the connector """
|
||||||
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/bw_search.json")
|
||||||
|
search_data = json.loads(datafile.read_bytes())
|
||||||
|
results = self.connector.parse_isbn_search_data(search_data)
|
||||||
|
result = self.connector.format_isbn_search_result(results[0])
|
||||||
|
self.assertEqual(result.connector, self.connector)
|
||||||
|
|
Loading…
Reference in New Issue