File: test_themes.py

package info (click to toggle)
bootstrap-flask 2.4.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,784 kB
  • sloc: python: 2,334; makefile: 30
file content (50 lines) | stat: -rw-r--r-- 1,436 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import current_app
import pytest


themes = [
    'cerulean',
    'cosmo',
    'cyborg',
    'darkly',
    'flatly',
    'journal',
    'litera',
    'lumen',
    'lux',
    'materia',
    'minty',
    'pulse',
    'sandstone',
    'simplex',
    'sketchy',
    'slate',
    'solar',
    'spacelab',
    'superhero',
    'united',
    'yeti'
]


@pytest.mark.parametrize('theme', 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', 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