Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (42 sloc) 1.601 kb
1501164 Daniel Lepage Add tests, fix docs.
authored
1 import unittest
2
3 from flask import Flask
4 from flask_raptor import init_app
5
6
7 class RaptorTestCase(unittest.TestCase):
8
9 def build_app(self):
10 app = Flask(__name__)
11 app.debug = True
12 app.secret_key = 'hunter2'
13 self.app = app
14
15 @app.route('/')
16 def foo():
17 return '<html><head></head><body>foo</body></html>'
18 return app
19
20 def test_raptorize(self):
21 app = self.build_app()
22 init_app(app)
23 response = app.test_client().get("/")
24 assert '/raptorizemw/resources/jquery.raptorize' in response.data
25
26 def test_resources(self):
27 app = self.build_app()
28 init_app(app)
29 response = app.test_client().get("/raptorizemw/resources/js_helper.js")
30 assert 'function include_js(url, success)' in response.data
31 assert response.status == "200 OK"
32
33 def test_options(self):
34 app = self.build_app()
35 app.config['RAPTOR_TRIGGER'] = 'konami-code'
36 # app.config['RAPTOR_CHANCE'] = .5
37 # app.config['RAPTOR_FOOLS'] = "true"
38 app.config['RAPTOR_DELAY'] = 5000
39 init_app(app)
40 response = app.test_client().get("/")
41 assert 'enterOn: "konami-code"' in response.data
42 assert 'delayTime: 5000' in response.data
43
44 def test_chance(self):
45 app = self.build_app()
46 app.config['RAPTOR_CHANCE'] = 0
47 init_app(app)
48 response = app.test_client().get("/")
49 assert '/raptorizemw/resources/jquery.raptorize' not in response.data
50
51
52 if __name__ == '__main__':
53 unittest.main()
54
Something went wrong with that request. Please try again.