def test_get_message_invalid_host_message_list(self):
        domain = "www.somedomain.com"
        k = mock.patch.dict(os.environ, {'NAGIOS_HOSTNAME': domain})
        k.start()
        nagios_notify = NagiosNotify()

        nagios_servicestate = None
        nagios_hoststate = "DOWN"
        service_message = "HOST: {0} Yum Update needs updating"
        service_message_list = ["NAGIOS_HOSTNAME"]
        host_message = "HOST: {0} Host is down"
        invalid_host_message_list = ["NAG_HOSTNAME"]

        with self.assertRaises(SystemExit) as cm:
            nagios_notify._get_message(nagios_servicestate, nagios_hoststate,
                                       service_message, service_message_list,
                                       host_message, invalid_host_message_list)
        k.stop()
        self.assertEqual(1, cm.exception.code)
    def test_get_message_host_message(self):
        domain = "www.somedomain.com"
        k = mock.patch.dict(os.environ, {'NAGIOS_HOSTNAME': domain})
        k.start()
        nagios_notify = NagiosNotify()

        nagios_servicestate = None
        nagios_hoststate = "DOWN"
        service_message = "HOST: {0} Yum Update needs updating"
        service_message_list = ["NAGIOS_HOSTNAME"]
        host_message = "HOST: {0} Host is down"
        host_message_list = ["NAGIOS_HOSTNAME"]

        message = nagios_notify._get_message(nagios_servicestate,
                                             nagios_hoststate, service_message,
                                             service_message_list,
                                             host_message, host_message_list)
        k.stop()
        self.assertEqual("HOST: www.somedomain.com Host is down", message)