mirror of
https://github.com/boostorg/website-v2.git
synced 2026-02-28 05:52:21 +00:00
This modernization occurs on the fly over potentially-cached S3 files. This means, the legacy doc pages are fetched and cached just like any other S3 static content, and the modernization happens when the page is requested. This way, we can safely render modern parts of the pages (like the header) and account for dynamic state such as logged in users. The resulting docs (also called FrankenDocs :-)) are processed using BeautifulSoup and a fairly simple heuristic that can be found in the `core/htmlhelper.py` module.
38 lines
1012 B
Python
38 lines
1012 B
Python
import pytest
|
|
from model_bakery import baker
|
|
|
|
|
|
@pytest.fixture
|
|
def rendered_content(db):
|
|
return baker.make(
|
|
"core.RenderedContent",
|
|
cache_key="cache-key",
|
|
content_original="Sample content",
|
|
content_html="<p>Sample content</p>",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_get_file_data(monkeypatch):
|
|
def _mock_get_file_data(
|
|
content,
|
|
content_s3_key,
|
|
content_s3_key_prefix="/archives/",
|
|
content_type="text/html",
|
|
):
|
|
def get_file_data(client, bucket_name, s3_key):
|
|
if f"{content_s3_key_prefix}{content_s3_key}" == s3_key:
|
|
result = {
|
|
"content": content,
|
|
"content_key": s3_key,
|
|
"content_type": content_type,
|
|
"last_modified": None,
|
|
}
|
|
else:
|
|
result = None
|
|
return result
|
|
|
|
monkeypatch.setattr("core.boostrenderer.get_file_data", get_file_data)
|
|
|
|
return _mock_get_file_data
|