Add: reactionner dead test in end_to_end test
[shinken.git] / test / test_db.py
blob8a9cb2c4d90982b5471d746b1a84ae635cacdaae
1 #!/usr/bin/env python2.6
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 # This file is used to test reading and processing of config files
25 #It's ugly I know....
26 from shinken_test import *
27 from shinken.db import DB
29 class TestConfig(ShinkenTest):
30 #setUp is in shinken_test
33 def create_db(self):
34 self.db = DB(table_prefix = 'test_')
36 #Change ME :)
37 def test_create_insert_query(self):
38 self.create_db()
39 data = {'id' : "1", "is_master" : True, 'plop' : "master of the universe"}
40 q = self.db.create_insert_query('instances' , data)
41 self.assert_(q == "INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , 'master of the universe' )")
44 def test_update_query(self):
45 self.create_db()
46 data = {'id' : "1", "is_master" : True, 'plop' : "master of the universe"}
47 where = {'id' : "1", "is_master" : True}
48 q = self.db.create_update_query('instances' , data, where)
49 #beware of the last space
50 self.assert_(q == "UPDATE test_instances set is_master='1' , id='1' , plop='master of the universe' WHERE is_master='1' and id='1' ")
54 if __name__ == '__main__':
55 unittest.main()