forked from dplepage/flask-raptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
54 lines (42 loc) · 1.56 KB
/
tests.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
import unittest
from flask import Flask
from flask_raptor import init_app
class RaptorTestCase(unittest.TestCase):
def build_app(self):
app = Flask(__name__)
app.debug = True
app.secret_key = 'hunter2'
self.app = app
@app.route('/')
def foo():
return '<html><head></head><body>foo</body></html>'
return app
def test_raptorize(self):
app = self.build_app()
init_app(app)
response = app.test_client().get("/")
assert '/raptorizemw/resources/jquery.raptorize' in response.data
def test_resources(self):
app = self.build_app()
init_app(app)
response = app.test_client().get("/raptorizemw/resources/js_helper.js")
assert 'function include_js(url, success)' in response.data
assert response.status == "200 OK"
def test_options(self):
app = self.build_app()
app.config['RAPTOR_TRIGGER'] = 'konami-code'
# app.config['RAPTOR_CHANCE'] = .5
# app.config['RAPTOR_FOOLS'] = "true"
app.config['RAPTOR_DELAY'] = 5000
init_app(app)
response = app.test_client().get("/")
assert 'enterOn: "konami-code"' in response.data
assert 'delayTime: 5000' in response.data
def test_chance(self):
app = self.build_app()
app.config['RAPTOR_CHANCE'] = 0
init_app(app)
response = app.test_client().get("/")
assert '/raptorizemw/resources/jquery.raptorize' not in response.data
if __name__ == '__main__':
unittest.main()