<NME> quick_tests.sh
<BEF> #!/bin/bash
# Copyright (C) 2009-2014:
#     Gabes Jean, naparuba@gmail.com
#     Gerhard Lausser, Gerhard.Lausser@consol.de
#
# This file is part of Shinken.
#
# Shinken is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Shinken is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Shinken.  If not, see <http://www.gnu.org/licenses/>.


DIR=$(cd $(dirname "$0"); pwd)
cd $DIR
echo "$PWD"

# delete the result of nosetest, for coverage
rm -f nosetests.xml
rm -f coverage.xml
rm -f .coverage*


chmod a+x *sh libexec/* ../libexec/*
dos2unix *sh libexec/*  ../libexec/*

rm -f var/lib/shinken/modules
mkdir -p var/lib/shinken/
ln -s ../../../../modules/  var/lib/shinken/modules

# Be sure that the symlink is done for the test conf in symlinks (to manage
# push from a windows dev host)
rm -f etc/conf_in_symlinks/links/link
ln -sf ../dest etc/conf_in_symlinks/links/link

function launch_and_assert {
    SCRIPT=$1
    # notice: the nose-cov is used because it is compatible with --processes, but produce a .coverage by process
    # so we must combine them in the end
    printf " - %-60s" $SCRIPT
    output=$(nosetests -xv --process-restartworker --processes=1 --process-timeout=999999999  --with-cov --cov=shinken  ./$SCRIPT > /tmp/test.running 2>&1)
    if [ $? != 0 ] ; then
        printf "\033[31m[ FAILED ]\033[0m\n"
	    echo "Error: the test $SCRIPT failed:"
	    cat /tmp/test.running
	    exit 2
    fi
    printf "\033[92m[ OK ]\033[0m\n"
launch_and_assert test_illegal_names.py
launch_and_assert test_notifway.py
launch_and_assert test_eventids.py
launch_and_assert test_notification_warning.py
launch_and_assert test_timeperiod_inheritance.py
launch_and_assert test_bad_timeperiods.py
# And create the coverage file
coverage combine

# Send to coveralls (if present, so if launch in TRAVIS)
coveralls

echo "Launchng pep8 now"
cd ..
pep8 --max-line-length=140 --ignore=E303,E302,E301,E241,W293,W291,E221,E126,E203,E129,E402 --exclude='*.pyc,*~,shinken/misc/*,shinken/webui/*' shinken/*
if [ $? != 0 ] ; then
   printf "PEP8 compliant: \033[31m[ FAILED ]\033[0m\n"
   exit 1
fi



echo "All unit tests did pass"

exit 0


<MSG> Enh: use the explode_global_conf functionality to send OxHP commands.

<DFF> @@ -57,6 +57,7 @@ launch_and_assert test_satellites.py
 launch_and_assert test_illegal_names.py
 launch_and_assert test_notifway.py
 launch_and_assert test_eventids.py
+launch_and_assert test_obsess.py
 launch_and_assert test_notification_warning.py
 launch_and_assert test_timeperiod_inheritance.py
 launch_and_assert test_bad_timeperiods.py

{'commit': 'diff --git a/shinken/config.py b/shinken/config.py\nindex be79d81a3..1f17d399f 100644\n--- a/shinken/config.py\n+++ b/shinken/config.py\n@@ -532,6 +532,12 @@ class Config(Item):\n     #and contacts directly in it\'s properties\n     #REMEMBER: linkify AFTER explode...\n     def linkify(self):\n+        \n+        #First linkify myself like for some global commands\n+        self.linkify_one_command_with_commands(self.commands, \'ocsp_command\')\n+        self.linkify_one_command_with_commands(self.commands, \'ochp_command\')\n+\n+\n         #Do the simplify AFTER explode groups\n         #print "Hostgroups"\n         #link hostgroups with hosts\n@@ -1100,16 +1106,12 @@ class Config(Item):\n \n \n     #Explode parameters like cached_service_check_horizon in the\n-    #Service class in a cached_check_horizon manner\n+    #Service class in a cached_check_horizon manner, o*hp commands\n+    #, etc\n     def explode_global_conf(self):\n         Service.load_global_conf(self)\n         Host.load_global_conf(self)\n         Contact.load_global_conf(self)\n-        # Host and Service classes can have properties which need to be \n-        # resolved to objects (like oc*p_command)\n-        Host.linkify(self)\n-        Service.linkify(self)\n-\n \n \n     #Clean useless elements like templates because they are not needed anymore\ndiff --git a/shinken/item.py b/shinken/item.py\nindex 79169cc73..4680fe6c1 100644\n--- a/shinken/item.py\n+++ b/shinken/item.py\n@@ -460,17 +460,18 @@ class Item(object):\n         \n         \n     #Link one command property to a class (for globals like oc*p_command)\n-    @classmethod\n-    def linkify_one_command_with_commands(cls, commands, prop):\n-        if hasattr(cls, prop):\n-            command = getattr(cls, prop).strip()\n+    def linkify_one_command_with_commands(self, commands, prop):\n+        if hasattr(self, prop):\n+            command = getattr(self, prop).strip()\n             if command != \'\':\n-                cmdCall = CommandCall(commands, command)\n-                #TODO: catch None?\n-                setattr(cls, prop, cmdCall)\n+                if hasattr(self, \'poller_tag\'):\n+                    cmdCall = CommandCall(commands, command, poller_tag=self.poller_tag)\n+                else:\n+                    cmdCall = CommandCall(commands, command)\n+                    #TODO: catch None?\n+                    setattr(self, prop, cmdCall)\n             else:\n-                setattr(cls, prop, None)\n-\n+                setattr(self, prop, None)\n \n             \n \ndiff --git a/test/quick_tests.sh b/test/quick_tests.sh\nindex ee01d4265..1ced8a2a8 100755\n--- a/test/quick_tests.sh\n+++ b/test/quick_tests.sh\n@@ -57,6 +57,7 @@ launch_and_assert test_satellites.py\n launch_and_assert test_illegal_names.py\n launch_and_assert test_notifway.py\n launch_and_assert test_eventids.py\n+launch_and_assert test_obsess.py\n launch_and_assert test_notification_warning.py\n launch_and_assert test_timeperiod_inheritance.py\n launch_and_assert test_bad_timeperiods.py\n', 'commit_subject': 'Enh: use the explode_global_conf functionality to send OxHP commands.', 'repo_name': 'naparuba/shinken', 'committer': {'name': 'Gabes Jean', 'email': 'c8e019fb2d4dd0d355144f4fa37aa9b8f4b57451@users.sourceforge.net', 'time_sec': '1287399043', 'tz_offset': '120', 'date': {'seconds': '1287399043'}}, 'commit_tree': '528f38eee6025c895ac74d41d02284471212b422', 'commit_message': 'Enh: use the explode_global_conf functionality to send OxHP commands.\n', 'language_name': 'Java', 'license': 'agpl-3.0', 'hunks': '@@ -57,6 +57,7 @@ launch_and_assert test_satellites.py\n launch_and_assert test_illegal_names.py\n launch_and_assert test_notifway.py\n launch_and_assert test_eventids.py\n+launch_and_assert test_obsess.py\n launch_and_assert test_notification_warning.py\n launch_and_assert test_timeperiod_inheritance.py\n launch_and_assert test_bad_timeperiods.py\n', 'addition_count': 1, 'deletion_count': 0, 'src_file': 'a/test/quick_tests.sh', 'tgt_file': 'b/test/quick_tests.sh', 'file_extension': '.sh', 'before_file': '#!/bin/bash\n# Copyright (C) 2009-2014:\n#     Gabes Jean, naparuba@gmail.com\n#     Gerhard Lausser, Gerhard.Lausser@consol.de\n#\n# This file is part of Shinken.\n#\n# Shinken is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Shinken is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with Shinken.  If not, see <http://www.gnu.org/licenses/>.\n\n\nDIR=$(cd $(dirname "$0"); pwd)\ncd $DIR\necho "$PWD"\n\n# delete the result of nosetest, for coverage\nrm -f nosetests.xml\nrm -f coverage.xml\nrm -f .coverage*\n\n\nchmod a+x *sh libexec/* ../libexec/*\ndos2unix *sh libexec/*  ../libexec/*\n\nrm -f var/lib/shinken/modules\nmkdir -p var/lib/shinken/\nln -s ../../../../modules/  var/lib/shinken/modules\n\n# Be sure that the symlink is done for the test conf in symlinks (to manage\n# push from a windows dev host)\nrm -f etc/conf_in_symlinks/links/link\nln -sf ../dest etc/conf_in_symlinks/links/link\n\nfunction launch_and_assert {\n    SCRIPT=$1\n    # notice: the nose-cov is used because it is compatible with --processes, but produce a .coverage by process\n    # so we must combine them in the end\n    printf " - %-60s" $SCRIPT\n    output=$(nosetests -xv --process-restartworker --processes=1 --process-timeout=999999999  --with-cov --cov=shinken  ./$SCRIPT > /tmp/test.running 2>&1)\n    if [ $? != 0 ] ; then\n        printf "\\033[31m[ FAILED ]\\033[0m\\n"\n\t    echo "Error: the test $SCRIPT failed:"\n\t    cat /tmp/test.running\n\t    exit 2\n    fi\n    printf "\\033[92m[ OK ]\\033[0m\\n"\nlaunch_and_assert test_illegal_names.py\nlaunch_and_assert test_notifway.py\nlaunch_and_assert test_eventids.py\nlaunch_and_assert test_notification_warning.py\nlaunch_and_assert test_timeperiod_inheritance.py\nlaunch_and_assert test_bad_timeperiods.py\n# And create the coverage file\ncoverage combine\n\n# Send to coveralls (if present, so if launch in TRAVIS)\ncoveralls\n\necho "Launchng pep8 now"\ncd ..\npep8 --max-line-length=140 --ignore=E303,E302,E301,E241,W293,W291,E221,E126,E203,E129,E402 --exclude=\'*.pyc,*~,shinken/misc/*,shinken/webui/*\' shinken/*\nif [ $? != 0 ] ; then\n   printf "PEP8 compliant: \\033[31m[ FAILED ]\\033[0m\\n"\n   exit 1\nfi\n\n\n\necho "All unit tests did pass"\n\nexit 0\n\n', 'message': 'Enh: use the explode_global_conf functionality to send OxHP commands.\n', 'author_name': 'Gabes Jean', 'lang': 'sh'}