|
7 | 7 | from unittest import TestCase |
8 | 8 | from ppp_core.exceptions import InvalidConfig |
9 | 9 |
|
10 | | -class InvalidConfFileTestCase(TestCase): |
| 10 | +class NoConfFileTestCase(TestCase): |
11 | 11 | def testNoConfFile(self): |
12 | 12 | self.app = TestApp(app) |
13 | 13 | obj = {'language': 'en', 'tree': {}} |
14 | 14 | self.assertRaises(InvalidConfig, self.app.post_json, |
15 | 15 | '/', obj, status='*') |
16 | 16 |
|
17 | | - def testEmptyConfFile(self): |
| 17 | +class InvalidConfFileTestCase(TestCase): |
| 18 | + def setUp(self): |
| 19 | + super(InvalidConfFileTestCase, self).setUp() |
18 | 20 | self.app = TestApp(app) |
19 | 21 | self.config_file = tempfile.NamedTemporaryFile('w+') |
20 | 22 | os.environ['PPP_CORE_CONFIG'] = self.config_file.name |
| 23 | + def tearDown(self): |
| 24 | + del os.environ['PPP_CORE_CONFIG'] |
| 25 | + self.config_file.close() |
| 26 | + del self.config_file |
| 27 | + super(InvalidConfFileTestCase, self).tearDown() |
| 28 | + def testEmptyConfFile(self): |
21 | 29 | obj = {'language': 'en', 'tree': {}} |
22 | 30 | self.assertRaises(InvalidConfig, self.app.post_json, |
23 | 31 | '/', obj, status='*') |
24 | | - del os.environ['PPP_CORE_CONFIG'] |
25 | | - del self.config_file |
26 | 32 |
|
27 | 33 | def testModuleWithNoName(self): |
28 | | - self.app = TestApp(app) |
29 | | - self.config_file = tempfile.NamedTemporaryFile('w+') |
30 | 34 | self.config_file.write('''{"debug": true, "modules": [{ |
31 | 35 | "url": "http://foo/bar/"}]}''') |
32 | 36 | self.config_file.seek(0) |
33 | | - os.environ['PPP_CORE_CONFIG'] = self.config_file.name |
34 | 37 | obj = {'language': 'en', 'tree': {}} |
35 | 38 | self.assertRaises(InvalidConfig, self.app.post_json, |
36 | 39 | '/', obj, status='*') |
37 | | - del os.environ['PPP_CORE_CONFIG'] |
38 | | - del self.config_file |
39 | 40 |
|
40 | 41 | def testModuleWithNoUrl(self): |
41 | | - self.app = TestApp(app) |
42 | | - self.config_file = tempfile.NamedTemporaryFile('w+') |
43 | 42 | self.config_file.write('''{"debug": true, "modules": [{ |
44 | 43 | "name": "foo"}]}''') |
45 | 44 | self.config_file.seek(0) |
46 | | - os.environ['PPP_CORE_CONFIG'] = self.config_file.name |
47 | 45 | obj = {'language': 'en', 'tree': {}} |
48 | 46 | self.assertRaises(InvalidConfig, self.app.post_json, |
49 | 47 | '/', obj, status='*') |
50 | | - del os.environ['PPP_CORE_CONFIG'] |
51 | | - del self.config_file |
0 commit comments