Passed
Push — master ( fb2dae...e99931 )
by -
01:28
created

FlaskrTestCase.test_download_db()   A

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3
Metric Value
cc 3
dl 0
loc 6
ccs 6
cts 6
cp 1
crap 3
rs 9.4285
1
2 1
from time import strftime, localtime
0 ignored issues
show
Unused Code introduced by
Unused localtime imported from time
Loading history...
Unused Code introduced by
Unused strftime imported from time
Loading history...
3
4 1
try:
5 1
    from urlparse import urlparse
6 1
    from StringIO import StringIO
7
except ImportError:  # python3
8
    from urllib.parse import urlparse
9
    from io.StringIO import StringIO
0 ignored issues
show
Configuration introduced by
The import io.StringIO could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
10
11 1
from spike import create_app
12 1
from spike.model import db
13 1
import unittest
14
15 1
class FlaskrTestCase(unittest.TestCase):
16 1
    def setUp(self):
17 1
        app = create_app()
18 1
        db.init_app(app)
19 1
        app.config['TESTING'] = True
20 1
        self.app = app.test_client()
21
22 1
    def tearDown(self):
23 1
        pass
24
25 1
    def test_robotstxt(self):
26 1
        assert self.app.get('/robots.txt').data == 'User-agent: *\n Disallow: /'
27
28 1
    def test_redirect_root(self):
29 1
        rv = self.app.get('/', follow_redirects=False)
0 ignored issues
show
Coding Style Naming introduced by
The name rv does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
30 1
        self.assertEqual(rv.status_code, 302)
31 1
        self.assertEqual(urlparse(rv.location).path, '/rules')
32
33 1
    def test_download_db(self):
34 1
        with open('./spike/rules.db', 'rb') as f:
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
35 1
            expected = StringIO(f.read())
36 1
        expected.seek(0)
37 1
        rv = self.app.get('/download')
0 ignored issues
show
Coding Style Naming introduced by
The name rv does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
38 1
        assert rv.data == expected.read()
39
40