1 | try: |
||
2 | from urlparse import urlparse |
||
3 | from StringIO import StringIO |
||
4 | except ImportError: # python3 |
||
5 | from urllib.parse import urlparse |
||
6 | from io import StringIO |
||
7 | |||
8 | from spike import create_app |
||
9 | from spike.model import db |
||
10 | import unittest |
||
11 | |||
12 | |||
13 | class FlaskrTestCase(unittest.TestCase): |
||
14 | def setUp(self): |
||
15 | app = create_app() |
||
16 | db.init_app(app) |
||
17 | app.config['TESTING'] = True |
||
18 | self.app = app.test_client() |
||
19 | |||
20 | def test_robotstxt(self): |
||
21 | self.assertEqual(self.app.get('/robots.txt').data, b'User-agent: *\n Disallow: /') |
||
22 | |||
23 | def test_redirect_root(self): |
||
24 | rv = self.app.get('/', follow_redirects=False) |
||
25 | self.assertEqual(rv.status_code, 302) |
||
26 | self.assertEqual(urlparse(rv.location).path, '/rules') |
||
27 | |||
28 | def test_download_db(self): |
||
29 | with open('./spike/rules.db', 'rb') as f: |
||
0 ignored issues
–
show
|
|||
30 | expected = StringIO(str(f.read())) |
||
31 | expected.seek(0) |
||
32 | rv = self.app.get('/download') |
||
33 | self.assertEqual(str(rv.data), expected.read()) |
||
34 | |||
35 | def test_atom(self): |
||
36 | rv = self.app.get('/rules.atom') |
||
37 | self.assertEqual(rv.status_code, 200) |
||
38 | self.assertIn('<feed xmlns="http://www.w3.org/2005/Atom">', str(rv.data)) |
||
39 |
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.