diff options
Diffstat (limited to 'test/test_config/test_db.py')
-rw-r--r-- | test/test_config/test_db.py | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/test/test_config/test_db.py b/test/test_config/test_db.py deleted file mode 100644 index ed46eae..0000000 --- a/test/test_config/test_db.py +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | # Copyright (C) 2010 Leonard Thomas | ||
2 | # | ||
3 | # This file is part of Dodai. | ||
4 | # | ||
5 | # Dodai is free software: you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation, either version 3 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # Dodai is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with Dodai. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | import unittest | ||
19 | import os | ||
20 | from dodai.config.db import ConfigDb | ||
21 | from dodai.config.db import ConfigDbFile | ||
22 | from dodai.config.db import BaseConfigDb | ||
23 | from dodai.config.db import NotConfigParserObject | ||
24 | from dodai.config.db import InvalidProtocolException | ||
25 | from dodai.config.db import InvalidPortException | ||
26 | from dodai.config.db import UnknownHandlerException | ||
27 | from dodai.config.db import UnknownConnectionException | ||
28 | from dodai.config.db.sa import Sa | ||
29 | from dodai.config.file import ConfigFile | ||
30 | from dodai.db import Db | ||
31 | |||
32 | class TestConfigDb(unittest.TestCase): | ||
33 | |||
34 | |||
35 | def setUp(self): | ||
36 | self.config_db = ConfigDb() | ||
37 | config = ConfigFile() | ||
38 | config.set_directory(os.path.dirname(os.path.abspath(__file__))) | ||
39 | config.load('config.cfg') | ||
40 | self.parser = config.parser() | ||
41 | |||
42 | def test_setup(self): | ||
43 | obj = self.config_db._handlers['sa'][0] | ||
44 | self.assertTrue(obj == Sa) | ||
45 | |||
46 | def test_register_handler(self): | ||
47 | self.config_db.register_handler('foo', Exception) | ||
48 | self.assertTrue('foo' in self.config_db._handlers.keys()) | ||
49 | |||
50 | def test_add_config_one(self): | ||
51 | self.config_db.add_config(config_parser=self.parser) | ||
52 | self.assertTrue('test_db' in self.config_db.connections.keys()) | ||
53 | |||
54 | def test_add_config_two(self): | ||
55 | self.failUnlessRaises(NotConfigParserObject, self.config_db.add_config, | ||
56 | config_parser='blah') | ||
57 | |||
58 | def test_load_one(self): | ||
59 | self.config_db.add_config(config_parser=self.parser) | ||
60 | obj = self.config_db.load('test_db') | ||
61 | self.assertTrue(isinstance(obj, Db)) | ||
62 | |||
63 | def test_load_two(self): | ||
64 | self.config_db.add_config(config_parser=self.parser) | ||
65 | obj = self.config_db.load('test_db') | ||
66 | obj = self.config_db.load('test_db') | ||
67 | self.assertTrue(isinstance(obj, Db)) | ||
68 | |||
69 | def test_load_handler(self): | ||
70 | self.failUnlessRaises(UnknownHandlerException, | ||
71 | self.config_db._load_handler, 'test') | ||
72 | |||
73 | def test_clean_protocol_one(self): | ||
74 | self.config_db.add_config(config_parser=self.parser) | ||
75 | obj = self.config_db.load('test_db_two') | ||
76 | self.assertTrue(isinstance(obj, Db)) | ||
77 | |||
78 | def test_clean_protocol_one(self): | ||
79 | self.config_db.add_config(config_parser=self.parser) | ||
80 | obj = self.config_db.load('test_db_two') | ||
81 | self.assertTrue(isinstance(obj, Db)) | ||
82 | |||
83 | def test_clean_protocol_two(self): | ||
84 | self.config_db.add_config(config_parser=self.parser) | ||
85 | self.failUnlessRaises(InvalidProtocolException, self.config_db.load, | ||
86 | 'test_db_three') | ||
87 | |||
88 | def test_clean_port_one(self): | ||
89 | obj = BaseConfigDb() | ||
90 | data = obj._clean_port('ad') | ||
91 | self.assertTrue(data == None) | ||
92 | |||
93 | def test_clean_port_two(self): | ||
94 | obj = BaseConfigDb() | ||
95 | data = obj._clean_port(None) | ||
96 | self.assertTrue(data == None) | ||
97 | |||
98 | def test_clean_port_three(self): | ||
99 | obj = BaseConfigDb() | ||
100 | self.failUnlessRaises(InvalidPortException, obj._clean_port, 66666) | ||
101 | |||
102 | |||
103 | def test_file_load_one(self): | ||
104 | self.config_db.add_config(config_parser=self.parser) | ||
105 | obj = self.config_db.load('test_db_six') | ||
106 | self.assertTrue(isinstance(obj, Db)) | ||