def test_send_event(self): fake_status = '42' fake_output = 'something went wrong' fake_soa_dir = '' expected_check_name = 'setup_chronos_job.%s' % compose_job_id( self.fake_service, self.fake_instance) with contextlib.nested( mock.patch("paasta_tools.monitoring_tools.send_event", autospec=True), mock.patch( "paasta_tools.chronos_tools.load_chronos_job_config", autospec=True), mock.patch( "paasta_tools.setup_chronos_job.load_system_paasta_config", autospec=True), ) as ( mock_send_event, mock_load_chronos_job_config, mock_load_system_paasta_config, ): mock_load_system_paasta_config.return_value.get_cluster = mock.Mock( return_value='fake_cluster') mock_load_chronos_job_config.return_value.get_monitoring.return_value = {} setup_chronos_job.send_event( service=self.fake_service, instance=self.fake_instance, soa_dir=fake_soa_dir, status=fake_status, output=fake_output, ) mock_send_event.assert_called_once_with( service=self.fake_service, check_name=expected_check_name, overrides={ 'alert_after': '10m', 'check_every': '10s' }, status=fake_status, output=fake_output, soa_dir=fake_soa_dir) mock_load_chronos_job_config.assert_called_once_with( service=self.fake_service, instance=self.fake_instance, cluster=mock_load_system_paasta_config.return_value. get_cluster.return_value, soa_dir=fake_soa_dir, )
def test_send_event(self): fake_status = "42" fake_output = "something went wrong" fake_soa_dir = "" expected_check_name = "setup_chronos_job.%s" % compose_job_id( self.fake_service, self.fake_instance) with mock.patch( "paasta_tools.monitoring_tools.send_event", autospec=True ) as mock_send_event, mock.patch( "paasta_tools.chronos_tools.load_chronos_job_config", autospec=True) as mock_load_chronos_job_config, mock.patch( "paasta_tools.setup_chronos_job.load_system_paasta_config", autospec=True) as mock_load_system_paasta_config: mock_load_system_paasta_config.return_value.get_cluster = mock.Mock( return_value="fake_cluster") mock_load_chronos_job_config.return_value.get_monitoring.return_value = {} setup_chronos_job.send_event( service=self.fake_service, instance=self.fake_instance, soa_dir=fake_soa_dir, status=fake_status, output=fake_output, ) mock_send_event.assert_called_once_with( service=self.fake_service, check_name=expected_check_name, overrides={ "alert_after": "10m", "check_every": "10s" }, status=fake_status, output=fake_output, soa_dir=fake_soa_dir, ) mock_load_chronos_job_config.assert_called_once_with( service=self.fake_service, instance=self.fake_instance, cluster=mock_load_system_paasta_config.return_value. get_cluster.return_value, soa_dir=fake_soa_dir, load_deployments=False, )
def test_send_event(self): fake_status = '42' fake_output = 'something went wrong' fake_soa_dir = '' expected_check_name = 'setup_chronos_job.%s' % compose_job_id(self.fake_service, self.fake_instance) with contextlib.nested( mock.patch("paasta_tools.monitoring_tools.send_event", autospec=True), mock.patch("paasta_tools.chronos_tools.load_chronos_job_config", autospec=True), mock.patch("paasta_tools.setup_chronos_job.load_system_paasta_config", autospec=True), ) as ( mock_send_event, mock_load_chronos_job_config, mock_load_system_paasta_config, ): mock_load_system_paasta_config.return_value.get_cluster = mock.Mock(return_value='fake_cluster') mock_load_chronos_job_config.return_value.get_monitoring.return_value = {} setup_chronos_job.send_event( service=self.fake_service, instance=self.fake_instance, soa_dir=fake_soa_dir, status=fake_status, output=fake_output, ) mock_send_event.assert_called_once_with( service=self.fake_service, check_name=expected_check_name, overrides={'alert_after': '10m', 'check_every': '10s'}, status=fake_status, output=fake_output, soa_dir=fake_soa_dir ) mock_load_chronos_job_config.assert_called_once_with( service=self.fake_service, instance=self.fake_instance, cluster=mock_load_system_paasta_config.return_value.get_cluster.return_value, soa_dir=fake_soa_dir, load_deployments=False, )