Passed
Branch master (e737b9)
by jvo
01:27
created

FlaskrTestCase.test_new()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
cc 1
dl 0
loc 4
ccs 4
cts 4
cp 1
crap 1
rs 10
1 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...
2
3 1
try:
4 1
    from urlparse import urlparse
5
except ImportError:  # python3
6
    from urllib.parse import urlparse
7
8 1
from spike import create_app, seeds
9 1
from spike.model import db
10 1
import unittest
11
12
13 1
class FlaskrTestCase(unittest.TestCase):
14 1
    def setUp(self):
15 1
        app = create_app('../config.cfg')
16 1
        db.init_app(app)
17 1
        app.config['TESTING'] = True
18 1
        self.app = app.test_client()
19
20 1
    def tearDown(self):
21 1
        pass
22
23 1
    def test_index(self):
24 1
        rv = self.app.get('/rulesets', 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...
25 1
        self.assertEqual(rv.status_code, 301)
26 1
        self.assertEqual(urlparse(rv.location).path, '/rulesets/')
27
28 1
        rv = self.app.get('/rulesets/', 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...
29 1
        self.assertEqual(rv.status_code, 200)
30
31 1
    def test_plain(self):
32 1
        rv = self.app.get('/rulesets/plain', 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...
33 1
        self.assertEqual(rv.status_code, 301)
34
35 1
        rv = self.app.get('/rulesets/plain', follow_redirects=True)
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...
36 1
        for seed in seeds.rulesets_seeds:
37 1
            self.assertIn(seed, rv.data)
38
39 1
        rv = self.app.get('/rulesets/plain/1', follow_redirects=True)
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...
40 1
        self.assertTrue(any(i for i in seeds.rulesets_seeds if i in rv.data))
41
42 1
    def test_new(self):
43 1
        rv = self.app.post('/rulesets/new', data={'rname': next(iter(seeds.rulesets_seeds))})
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (93/90).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
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...
44
        self.assertEqual(rv.status_code, 302)
45
        self.assertEqual(urlparse(rv.location).path, '/rulesets/')
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...