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
28 from shinken_test
import *
29 from shinken
.action
import Action
31 class TestConfig(ShinkenTest
):
32 #setUp is in shinken_test
34 def wait_finished(self
, a
):
35 for i
in xrange(1, 10000):
36 if a
.status
== 'launched':
37 a
.check_finished(8012)
40 def test_action(self
):
46 a
.command
= "./dummy_command.cmd"
48 a
.command
= "./dummy_command.sh"
49 self
.assert_(a
.got_shell_caracters() == False)
51 self
.assert_(a
.status
== 'launched')
52 #Give also the max output we want for the command
54 self
.assert_(a
.exit_status
== 0)
55 self
.assert_(a
.status
== 'done')
56 self
.assert_(a
.output
== "Hi, I'm for testing only. Please do not use me directly, really")
57 self
.assert_(a
.perf_data
== "Hip=99% Bob=34mm")
60 def test_environnement_variables(self
):
66 a
.command
= "/usr/bin/env"
67 a
.env
= {'TITI' : 'est en vacance'}
69 self
.assert_(a
.got_shell_caracters() == False)
73 self
.assert_(a
.status
== 'launched')
74 #Give also the max output we want for the command
76 print "Output", a
.long_output
, a
.output
78 for l
in a
.long_output
.splitlines():
79 if l
== 'TITI=est en vacance':
82 self
.assert_(titi_found
== True)
85 #Some commands are shell without bangs! (like in Centreon...)
86 #We can show it in the launch, and it should be managed
87 def test_noshell_bang_command(self
):
90 a
.command
= "./dummy_command_nobang.sh"
94 self
.assert_(a
.got_shell_caracters() == False)
97 self
.assert_(a
.status
== 'launched')
99 print "FUck", a
.status
, a
.output
100 self
.assert_(a
.exit_status
== 0)
101 self
.assert_(a
.status
== 'done')
105 if __name__
== '__main__':