Merge branch 'master' of ssh://naparuba@shinken.git.sourceforge.net/gitroot/shinken...
[shinken.git] / test / test_properties.py
blob8fb0106797ce087df099526f9e45962fc64f6545
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.property import UnusedProp, BoolProp, IntegerProp, FloatProp, CharProp, StringProp
29 class TestConfig(ShinkenTest):
30 #Uncomment this is you want to use a specific configuration
31 #for your test
32 def setUp(self):
33 pass
36 #Test the bool property class
37 def test_bool_property(self):
38 p = BoolProp(default='1', class_inherit=[('Host', 'accept_passive_checks')])
39 print p.__dict__
40 s = "1"
41 val = p.pythonize(s)
42 print s, val
43 self.assert_(val == True)
44 s = "0"
45 val = p.pythonize(s)
46 print s, val
47 self.assert_(val == False)
49 #Now a service one
50 p = BoolProp(default='0', fill_brok=['full_status'])
51 print p.__dict__
52 s = "1"
53 val = p.pythonize(s)
54 print s, val
55 self.assert_(val == True)
56 self.assert_('full_status' in p.fill_brok)
59 if __name__ == '__main__':
60 unittest.main()