open-law/tests/test_build_qa_url_using_int...

38 lines
1.0 KiB
Python
Raw Normal View History

2023-05-19 08:08:52 +00:00
from flask.testing import FlaskClient
from flask import current_app as Response
from app.controllers.jinja_globals import (
build_qa_url_using_interpretation,
)
2023-06-12 13:14:17 +00:00
from .utils import (
create_book,
login,
create_collection,
create_section,
create_interpretation,
create_comment,
)
2023-05-19 08:08:52 +00:00
from app import models as m
def test_build_qa_url_using_interpretation(client: FlaskClient):
2023-06-12 13:14:17 +00:00
login(client)
2023-05-19 08:08:52 +00:00
2023-06-12 13:14:17 +00:00
book = create_book(client)
collection, _ = create_collection(client, book.id)
section, _ = create_section(client, book.id, collection.id)
interpretation, _ = create_interpretation(client, book.id, section.id)
create_comment(client, book.id, interpretation.id)
2023-05-19 08:08:52 +00:00
interpretation: m.Interpretation = m.Interpretation.query.first()
url = build_qa_url_using_interpretation(interpretation)
assert url
response: Response = client.get(url, follow_redirects=True)
assert response.status_code == 200
section: m.Section = m.Section.query.first()
assert section
assert str.encode(section.label) in response.data