Merge branch 'master' of ssh://lausser,shinken@shinken.git.sourceforge.net/gitroot...
[shinken.git] / test / test_not_hostname.py
blob2f0daa677c6dafb18a3dcde498566072bb3df934
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 import time
27 from shinken_test import unittest, ShinkenTest
30 class TestConfig(ShinkenTest):
32 def setUp(self):
33 self.setup_with_file('etc/nagios_not_hostname.cfg')
36 #Change ME :)
37 def test_not_hostname_in_service(self):
38 #The service is apply with a host_group on "test_host_0","test_host_1"
39 #but have a host_name with !"test_host_1" so there will be just "test_host_0"
40 #defined on the end
41 print "Get the hosts and services"
42 now = time.time()
43 host = self.sched.hosts.find_by_name("test_host_0")
44 host.checks_in_progress = []
45 host.act_depend_of = [] # ignore the router
46 router = self.sched.hosts.find_by_name("test_router_0")
47 router.checks_in_progress = []
48 router.act_depend_of = [] # ignore the router
49 svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
50 svc.checks_in_progress = []
51 svc.act_depend_of = [] # no hostchecks on critical checkresults
52 svc_not = self.sched.services.find_srv_by_name_and_hostname("test_host_1", "test_ok_0")
53 #Check if the service for the good host is here
54 self.assert_(svc is not None)
55 #check if the service for the not one (!) is not here
56 self.assert_(svc_not is None)
60 if __name__ == '__main__':
61 unittest.main()