tests.InvalidConfFileTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 15
ccs 14
cts 14
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testEmptyConfFile() 0 4 1
A tearDown() 0 5 1
1
"""Tests what happens if the config file is invalid."""
2
3 1
import os
4 1
import tempfile
5 1
from ppp_logger import app
6 1
from webtest import TestApp
7 1
from unittest import TestCase
8 1
from ppp_libmodule.exceptions import InvalidConfig
9
10
11 1
class NoConfFileTestCase(TestCase):
12 1
    def testNoConfFile(self):
13 1
        self.app = TestApp(app)
14 1
        obj = {'id': 'foobar', 'question': '42?', 'responses': []}
15 1
        self.assertRaises(InvalidConfig, self.app.post_json,
16
                          '/', obj, status='*')
17
18 1
class InvalidConfFileTestCase(TestCase):
19 1
    def setUp(self):
20 1
        super(InvalidConfFileTestCase, self).setUp()
21 1
        self.app = TestApp(app)
22 1
        self.config_file = tempfile.NamedTemporaryFile('w+')
23 1
        os.environ['PPP_LOGGER_CONFIG'] = self.config_file.name
24 1
    def tearDown(self):
25 1
        del os.environ['PPP_LOGGER_CONFIG']
26 1
        self.config_file.close()
27 1
        del self.config_file
28 1
        super(InvalidConfFileTestCase, self).tearDown()
29 1
    def testEmptyConfFile(self):
30 1
        obj = {'id': 'foobar', 'question': '42?', 'responses': []}
31 1
        self.assertRaises(InvalidConfig, self.app.post_json,
32
                          '/', obj, status='*')
33