Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements/tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest
pytest-cov
flask-wtf
flask-sqlalchemy
beautifulsoup4
Comment thread
greyli marked this conversation as resolved.
10 changes: 8 additions & 2 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SHA1:2bce3613bf781b5318773bbd23ef6330092309f9
# SHA1:34838a637a8bb69340f90a1de71e46b007e4a5d6
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
beautifulsoup4==4.13.4
# via -r requirements/tests.in
blinker==1.8.2
# via flask
click==8.1.8
Expand Down Expand Up @@ -50,12 +52,16 @@ pytest-cov==5.0.0
# via -r requirements/tests.in
sqlalchemy==2.0.38
# via flask-sqlalchemy
soupsieve==2.7
# via beautifulsoup4
tomli==2.2.1
# via
# coverage
# pytest
typing-extensions==4.12.2
# via sqlalchemy
# via
# beautifulsoup4
# sqlalchemy
werkzeug==3.0.6
# via flask
wtforms==3.1.2
Expand Down
32 changes: 32 additions & 0 deletions tests/test_bootstrap5/test_integrity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
from bs4 import BeautifulSoup
from flask import Flask, render_template_string


@pytest.fixture
def app():
app = Flask(__name__)
app.secret_key = "test"
return app


def test_cdn_integrity(app):
@app.route("/")
def index():
return render_template_string(
"{{ bootstrap.load_css() }}{{ bootstrap.load_js() }}"
)

client = app.test_client()
response = client.get("/")
html = response.get_data(as_text=True)
soup = BeautifulSoup(html, "html.parser")

css = soup.find("link", rel="stylesheet")
js = soup.find("script", src=lambda s: s and "bootstrap" in s)

bootstrap = app.extensions["bootstrap"]
assert css["integrity"] == bootstrap.bootstrap_css_integrity
assert js["integrity"] == bootstrap.bootstrap_js_integrity
assert css["crossorigin"] == "anonymous"
assert js["crossorigin"] == "anonymous"