From 9c6db1cc0e27f7206a17584cd86eb28cd43e420d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 3 Dec 2020 13:22:50 -0800 Subject: [PATCH] Updates connector tests --- .../connectors/test_abstract_connector.py | 4 ++-- .../connectors/test_bookwyrm_connector.py | 21 ++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/bookwyrm/tests/connectors/test_abstract_connector.py b/bookwyrm/tests/connectors/test_abstract_connector.py index c01b00dba..f05645ab1 100644 --- a/bookwyrm/tests/connectors/test_abstract_connector.py +++ b/bookwyrm/tests/connectors/test_abstract_connector.py @@ -3,7 +3,7 @@ from django.test import TestCase from bookwyrm import models from bookwyrm.connectors.abstract_connector import Mapping -from bookwyrm.connectors.bookwyrm_connector import Connector +from bookwyrm.connectors.openlibrary import Connector class AbstractConnector(TestCase): @@ -12,7 +12,7 @@ class AbstractConnector(TestCase): models.Connector.objects.create( identifier='example.com', - connector_file='bookwyrm_connector', + connector_file='openlibrary', base_url='https://example.com', books_url='https:/example.com', covers_url='https://example.com', diff --git a/bookwyrm/tests/connectors/test_bookwyrm_connector.py b/bookwyrm/tests/connectors/test_bookwyrm_connector.py index c41b454c6..8d866ca25 100644 --- a/bookwyrm/tests/connectors/test_bookwyrm_connector.py +++ b/bookwyrm/tests/connectors/test_bookwyrm_connector.py @@ -1,16 +1,17 @@ ''' testing book data connectors ''' -from dateutil import parser -from django.test import TestCase import json import pathlib +from django.test import TestCase from bookwyrm import models from bookwyrm.connectors.bookwyrm_connector import Connector -from bookwyrm.connectors.abstract_connector import SearchResult, get_date +from bookwyrm.connectors.abstract_connector import SearchResult class BookWyrmConnector(TestCase): + ''' this connector doesn't do much, just search ''' def setUp(self): + ''' create the connector ''' models.Connector.objects.create( identifier='example.com', connector_file='bookwyrm_connector', @@ -29,13 +30,9 @@ class BookWyrmConnector(TestCase): self.edition_data = json.loads(edition_file.read_bytes()) - def test_is_work_data(self): - self.assertEqual(self.connector.is_work_data(self.work_data), True) - self.assertEqual(self.connector.is_work_data(self.edition_data), False) - - def test_format_search_result(self): - datafile = pathlib.Path(__file__).parent.joinpath('../data/fr_search.json') + datafile = pathlib.Path(__file__).parent.joinpath( + '../data/fr_search.json') search_data = json.loads(datafile.read_bytes()) results = self.connector.parse_search_data(search_data) self.assertIsInstance(results, list) @@ -46,9 +43,3 @@ class BookWyrmConnector(TestCase): self.assertEqual(result.key, 'https://example.com/book/122') self.assertEqual(result.author, 'Susanna Clarke') self.assertEqual(result.year, 2017) - - - def test_get_date(self): - date = get_date(self.edition_data['published_date']) - expected = parser.parse("2020-09-15T00:00:00+00:00") - self.assertEqual(date, expected)