forked from nickjj/flask-static-digest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
77 lines (55 loc) · 1.92 KB
/
conftest.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import pytest
from flask import Flask, Blueprint, testing, jsonify, make_response
from flask_cache_manifest import FlaskCacheManifest
class TestClient(testing.FlaskClient):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def create_app():
flaskapp = Flask('flask-ext',
static_folder='./tests/data/bundle1',
static_url_path='/static')
flaskapp.config.update({
'TEST': True,
})
flaskapp.url_map.strict_slashes = True
flaskapp.test_client_class = TestClient
bp_one = Blueprint("one",
__name__,
url_prefix="/one",
static_url_path='static',
static_folder="./tests/data/bundle2")
bp_two = Blueprint("two",
__name__,
static_url_path="/two-static",
static_folder="./tests/data/bundle3")
bp_one_a = Blueprint("a", __name__,
template_folder="./templates",
static_url_path="/a/static",
static_folder="./tests/data/bundle3")
bp_one_b = Blueprint("b", __name__)
@flaskapp.route('/')
@bp_one.route('/')
@bp_two.route('/two')
@bp_one_a.route('/a')
@bp_one_b.route('/b')
def mockRoute():
return make_response(jsonify.dumps({}), 200)
bp_one.register_blueprint(bp_one_a)
bp_one.register_blueprint(bp_one_b)
flaskapp.register_blueprint(bp_one)
flaskapp.register_blueprint(bp_two)
return flaskapp
@pytest.fixture
def appFactory():
return create_app
@pytest.fixture
def app(appFactory):
flaskapp = appFactory()
flaskCacheManifest = FlaskCacheManifest()
flaskCacheManifest.init_app(flaskapp)
yield flaskapp
@pytest.fixture
def client(app):
with app.test_client() as client:
with app.app_context():
yield client