From 604a66fc0bc66e5056de344029c1ecdecfbbc32f Mon Sep 17 00:00:00 2001 From: Kostiantyn Stoliarskyi Date: Thu, 8 Jun 2023 17:36:40 +0300 Subject: [PATCH] fix tests --- app/views/book/interpretation.py | 10 +++++----- tests/test_upvote.py | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/views/book/interpretation.py b/app/views/book/interpretation.py index f39dff3..c09aa37 100644 --- a/app/views/book/interpretation.py +++ b/app/views/book/interpretation.py @@ -218,13 +218,13 @@ def interpretation_delete( delete_nested_interpretation_entities(interpretation) log(log.INFO, "Delete interpretation [%s]", interpretation) interpretation.save() + redirect_url = url_for( + "book.interpretation_view", + book_id=book_id, + section_id=interpretation.section_id, + ) # notifications if current_user.id != interpretation.user_id: - redirect_url = url_for( - "book.interpretation_view", - book_id=book_id, - section_id=interpretation.section_id, - ) notification_text = "A moderator has removed your interpretation" m.Notification( link=redirect_url, diff --git a/tests/test_upvote.py b/tests/test_upvote.py index 0ba3598..46a1a14 100644 --- a/tests/test_upvote.py +++ b/tests/test_upvote.py @@ -2,7 +2,13 @@ from flask import current_app as Response from flask.testing import FlaskClient from app import models as m -from tests.utils import login +from tests.utils import ( + login, + create_interpretation, + create_section, + create_book, + create_collection, +) def test_upvote_interpretation(client: FlaskClient): @@ -21,10 +27,17 @@ def test_upvote_interpretation(client: FlaskClient): assert response.status_code == 404 assert response.json["message"] == "Interpretation not found" - interpretation = m.Interpretation( - text="Test Interpretation 1 Text", - user_id=user.id, - ).save() + book = create_book(client) + assert book + collection, _ = create_collection(client=client, book_id=book.id) + assert collection + section, _ = create_section( + client=client, book_id=book.id, collection_id=collection.id + ) + assert section + interpretation, _ = create_interpretation( + client=client, book_id=book.id, section_id=section.id + ) assert interpretation.vote_count == 0