File: test_themes.py

package info (click to toggle)
bootstrap-flask 2.2.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 25,396 kB
  • sloc: python: 2,218; makefile: 24
file content (34 lines) | stat: -rw-r--r-- 1,289 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import current_app
import pytest
from tests.test_bootstrap4.test_themes import themes


bootstrap5_themes = themes + [
    'morph',
    'quartz',
    'vapor',
    'zephyr',
]


@pytest.mark.parametrize('theme', bootstrap5_themes)
def test_bootswatch_local(theme, client):
    current_app.config['BOOTSTRAP_SERVE_LOCAL'] = True
    current_app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = theme
    data = client.get('/').get_data(as_text=True)
    assert 'https://cdn.jsdelivr.net/npm/bootswatch' not in data
    assert f'bootswatch/{theme}/bootstrap.min.css' in data
    with client.get(f'/bootstrap/static/css/bootswatch/{theme}/bootstrap.min.css') as css_response:
        assert css_response.status_code != 404


@pytest.mark.parametrize('theme', bootstrap5_themes)
def test_bootswatch_cdn(bootstrap, theme, client):
    current_app.config['BOOTSTRAP_SERVE_LOCAL'] = False
    current_app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = theme
    data = client.get('/').get_data(as_text=True)
    assert 'https://cdn.jsdelivr.net/npm/bootswatch' in data
    assert f'dist/{theme}/bootstrap.min.css' in data
    css_rv = bootstrap.load_css()
    assert f'/bootstrap/static/css/bootswatch/{theme}/bootstrap.min.css' not in data
    assert 'https://cdn.jsdelivr.net/npm/bootswatch' in css_rv