fix breadcrumbs tests

This commit is contained in:
SvyatoslavArtymovych 2023-06-12 16:12:12 +03:00
parent ba860fe59d
commit 1bdf045adc
2 changed files with 9 additions and 6 deletions

View File

@ -17,8 +17,6 @@ from tests.utils import (
create_collection,
create_section,
create_sub_collection,
create_interpretation,
create_comment,
)

View File

@ -1,12 +1,17 @@
from flask.testing import FlaskCliRunner
from app.controllers import create_breadcrumbs
from app import models as m, db
from tests.utils import create_book, login, create_collection, create_section
def test_breadcrumbs(runner: FlaskCliRunner, app):
runner.invoke(args=["db-populate"])
def test_breadcrumbs(client, app):
login(client)
book = create_book(client)
collection, _ = create_collection(client, book.id)
section, _ = create_section(client, book.id, collection.id)
with app.app_context(), app.test_request_context():
res = create_breadcrumbs(book_id=1, collection_id=1, section_id=1)
res = create_breadcrumbs(
book_id=book.id, collection_id=collection.id, section_id=section.id
)
assert len(res) == 4
book: m.Book = db.session.get(m.Book, 1)
assert book