Hopefully knocking out many of the unit test fails

This commit is contained in:
Vivianne Langdon 2022-03-02 03:11:02 -08:00
parent 440e2f8806
commit 05f11e68c5
6 changed files with 8 additions and 7 deletions

View file

@ -89,7 +89,7 @@ class AbstractConnector(TestCase):
def test_get_or_create_book_existing(self):
"""find an existing book by remote/origin id"""
self.assertEqual(models.Book.objects.count(), 1)
self.assertEqual(self.book.remote_id, f"https://{DOMAIN}/book/{self.book.id}")
self.assertEqual(self.book.remote_id, f"https://{DOMAIN}/book/{self.book.id}/s/test-book")
self.assertEqual(self.book.origin_id, "https://example.com/book/1234")
# dedupe by origin id

View file

@ -27,7 +27,7 @@ class List(TestCase):
book_list = models.List.objects.create(
name="Test List", user=self.local_user
)
expected_id = f"https://{settings.DOMAIN}/list/{book_list.id}"
expected_id = f"https://{settings.DOMAIN}/list/{book_list.id}/s/test-list"
self.assertEqual(book_list.get_remote_id(), expected_id)
def test_to_activity(self, _):

View file

@ -48,7 +48,7 @@ class IsbnViews(TestCase):
data = json.loads(response.content)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]["title"], "Test Book")
self.assertEqual(data[0]["key"], f"https://{DOMAIN}/book/{self.book.id}")
self.assertEqual(data[0]["key"], f"https://{DOMAIN}/book/{self.book.id}/s/test-book")
def test_isbn_html_response(self):
"""searches local data only and returns book data in json format"""

View file

@ -52,7 +52,7 @@ class Views(TestCase):
data = json.loads(response.content)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]["title"], "Test Book")
self.assertEqual(data[0]["key"], f"https://{DOMAIN}/book/{self.book.id}")
self.assertEqual(data[0]["key"], f"https://{DOMAIN}/book/{self.book.id}/s/test-book")
def test_search_no_query(self):
"""just the search page"""

View file

@ -209,7 +209,9 @@ def maybe_redirect_local_path(request, model):
if the request had an invalid path, return a permanent redirect response to the correct one, including a slug if any.
if path is valid, returns False.
"""
if request.path == model.local_path:
# don't redirect empty path for unit tests which currently have this
if request.path == "" or request.path == model.local_path:
return False
new_path = model.local_path

View file

@ -21,9 +21,8 @@ from bookwyrm.views.helpers import is_api_request, get_user_from_username
class Shelf(View):
"""shelf page"""
def get(self, request, username, **kwargs):
def get(self, request, username, shelf_identifier=None):
"""display a shelf"""
shelf_identifier = kwargs.get("shelf_identifier")
user = get_user_from_username(request.user, username)
is_self = user == request.user