2023-05-01 14:01:03 +00:00
|
|
|
from flask.testing import FlaskCliRunner
|
|
|
|
from app.controllers import create_breadcrumbs
|
|
|
|
from app import models as m, db
|
|
|
|
|
|
|
|
|
|
|
|
def test_breadcrumbs(runner: FlaskCliRunner, app):
|
|
|
|
runner.invoke(args=["db-populate"])
|
|
|
|
with app.app_context(), app.test_request_context():
|
2023-05-30 13:45:32 +00:00
|
|
|
res = create_breadcrumbs(book_id=1, collection_id=1, section_id=1)
|
2023-05-01 14:01:03 +00:00
|
|
|
assert len(res) == 4
|
|
|
|
book: m.Book = db.session.get(m.Book, 1)
|
|
|
|
assert book
|
|
|
|
assert book.owner.username in res[0].label
|
|
|
|
assert res[1].label == book.label
|
|
|
|
with app.app_context(), app.test_request_context():
|
2023-05-30 13:45:32 +00:00
|
|
|
res = create_breadcrumbs(book_id=1, section_id=1)
|
2023-05-01 14:01:03 +00:00
|
|
|
assert res
|
2023-05-30 13:45:32 +00:00
|
|
|
assert len(res) == 4
|