This commit is contained in:
SvyatoslavArtymovych 2023-06-01 07:59:37 +03:00
parent 94197172b8
commit 28b0946f6a
2 changed files with 9 additions and 20 deletions

View File

@ -1,5 +1,4 @@
# flake8: noqa F501 from flask import current_app as Response
from flask import current_app as Response, url_for
from flask.testing import FlaskClient, FlaskCliRunner from flask.testing import FlaskClient, FlaskCliRunner
from app import models as m, db from app import models as m, db
@ -115,7 +114,7 @@ def test_create_edit_delete_book(client: FlaskClient):
assert response.status_code == 200 assert response.status_code == 200
assert b"Success!" in response.data assert b"Success!" in response.data
book = db.session.get(m.Book, book.id) book = db.session.get(m.Book, book.id)
assert book.is_deleted == True assert book.is_deleted
check_if_nested_book_entities_is_deleted(book) check_if_nested_book_entities_is_deleted(book)
@ -263,7 +262,7 @@ def test_edit_contributor_role(client: FlaskClient, runner: FlaskCliRunner):
assert b"You do not have permission" in response.data assert b"You do not have permission" in response.data
response: Response = client.post( response: Response = client.post(
f"/book/999/add_contributor", "/book/999/add_contributor",
data=dict(user_id=moderator.id, role=m.BookContributor.Roles.MODERATOR), data=dict(user_id=moderator.id, role=m.BookContributor.Roles.MODERATOR),
follow_redirects=True, follow_redirects=True,
) )
@ -296,7 +295,7 @@ def test_crud_collection(client: FlaskClient):
assert b"Collection label must be unique!" in response.data assert b"Collection label must be unique!" in response.data
response: Response = client.post( response: Response = client.post(
f"/book/999/create_collection", "/book/999/create_collection",
data=dict(label="Test Collection #1 Label", about="Test Collection #1 About"), data=dict(label="Test Collection #1 Label", about="Test Collection #1 About"),
follow_redirects=True, follow_redirects=True,
) )
@ -978,7 +977,7 @@ def test_crud_comment(client: FlaskClient, runner: FlaskCliRunner):
is_leaf=True, is_leaf=True,
parent_id=book.last_version.root_collection.id, parent_id=book.last_version.root_collection.id,
).save() ).save()
section_in_collection: m.Section = m.Section( m.Section(
label="Test Section in Collection #1 Label", label="Test Section in Collection #1 Label",
collection_id=leaf_collection.id, collection_id=leaf_collection.id,
version_id=book.last_version.id, version_id=book.last_version.id,
@ -1215,7 +1214,7 @@ def test_interpretation_in_home_last_inter_section(
assert b"Section not found" in response.data assert b"Section not found" in response.data
response: Response = client.get( response: Response = client.get(
f"/home", "/home",
follow_redirects=True, follow_redirects=True,
) )

View File

@ -1,19 +1,9 @@
from random import randint from random import randint
from flask import current_app as Response, url_for from flask import current_app as Response
from flask.testing import FlaskClient, FlaskCliRunner
from app import models as m, db from app import models as m
from app.controllers.create_access_groups import create_moderator_group from tests.utils import login, logout
from tests.utils import (
login,
logout,
check_if_nested_book_entities_is_deleted,
check_if_nested_collection_entities_is_deleted,
check_if_nested_section_entities_is_deleted,
check_if_nested_interpretation_entities_is_deleted,
create_test_book,
)
def create_book(client): def create_book(client):