add tests. black

This commit is contained in:
qilinz 2023-07-13 16:32:09 +02:00 committed by Henri Dickson
parent 56f219b617
commit 73d085845c
3 changed files with 22 additions and 4 deletions

View file

@ -96,6 +96,24 @@ class ShelfTest(TestCase):
self.assertEqual(Mark(user, book1).visibility, 1)
self.assertEqual(shelf_manager.get_log_for_item(book1).count(), 5)
# test silence mark mode -> no log
shelf_manager.move_item(book1, ShelfType.WISHLIST, silence=True)
self.assertEqual(log.count(), 5)
shelf_manager.move_item(book1, ShelfType.PROGRESS, silence=True)
self.assertEqual(log.count(), 5)
# test delete one log
first_log = log.first()
Mark(user, book1).delete_log(first_log.id)
self.assertEqual(log.count(), 4)
# test delete mark -> leave one log: 移除标记
Mark(user, book1).delete()
self.assertEqual(log.count(), 1)
# test delete all logs
shelf_manager.move_item(book1, ShelfType.PROGRESS)
self.assertEqual(log.count(), 2)
Mark(user, book1).delete(silence=True)
self.assertEqual(log.count(), 0)
class TagTest(TestCase):
def setUp(self):

View file

@ -23,9 +23,7 @@ urlpatterns = [
path("mark/<str:item_uuid>", mark, name="mark"),
path("comment/<str:item_uuid>", comment, name="comment"),
path("mark_log/<str:item_uuid>/<str:log_id>", mark_log, name="mark_log"),
path(
"mark_history/<str:item_uuid>", mark_history, name="mark_history"
),
path("mark_history/<str:item_uuid>", mark_history, name="mark_history"),
path(
"add_to_collection/<str:item_uuid>", add_to_collection, name="add_to_collection"
),

View file

@ -161,7 +161,9 @@ def mark(request, item_uuid):
if request.POST.get("delete", default=False):
silence = request.POST.get("silence", False)
mark.delete(silence=silence)
if silence: # this means the mark is deleted from mark_history, thus redirect to item page
if (
silence
): # this means the mark is deleted from mark_history, thus redirect to item page
return redirect(
reverse("catalog:retrieve", args=[item.url_path, item.uuid])
)