Example #1
0
 def test_bounce_chronos_job_takes_actions(self):
     fake_job_to_update = {'name': 'job_to_update'}
     with mock.patch(
             "paasta_tools.setup_chronos_job._log",
             autospec=True,
     ) as mock_log, mock.patch(
             "paasta_tools.chronos_tools.update_job",
             autospec=True,
     ) as mock_update_job:
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             job_to_update=fake_job_to_update,
             client=self.fake_client,
         )
         mock_log.assert_any_call(
             line=mock.ANY,
             level='debug',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_log.assert_any_call(
             line="Updated Chronos job: job_to_update",
             level='event',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_update_job.assert_called_once_with(job=fake_job_to_update,
                                                 client=self.fake_client)
 def test_bounce_chronos_job_takes_actions(self):
     fake_job_to_update = {'name': 'job_to_update'}
     with contextlib.nested(
         mock.patch("paasta_tools.setup_chronos_job._log", autospec=True),
         mock.patch("paasta_tools.chronos_tools.update_job", autospec=True),
     ) as (
         mock_log,
         mock_update_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             job_to_update=fake_job_to_update,
             client=self.fake_client,
         )
         mock_log.assert_any_call(
             line=mock.ANY,
             level='debug',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_log.assert_any_call(
             line="Updated Chronos job: job_to_update",
             level='event',
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             component='deploy',
             service=self.fake_service,
         )
         mock_update_job.assert_called_once_with(job=fake_job_to_update, client=self.fake_client)
Example #3
0
 def test_bounce_chronos_job_doesnt_log_when_nothing_to_do(self):
     with mock.patch("paasta_tools.setup_chronos_job._log",
                     autospec=True) as mock_log, mock.patch(
                         "paasta_tools.chronos_tools.update_job",
                         autospec=True) as mock_update_job:
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             job_to_update=None,
             client=self.fake_client,
         )
         assert not mock_log.called
         assert not mock_update_job.called
 def test_bounce_chronos_job_doesnt_log_when_nothing_to_do(self):
     with contextlib.nested(
         mock.patch("paasta_tools.setup_chronos_job._log", autospec=True),
         mock.patch("paasta_tools.chronos_tools.update_job", autospec=True),
     ) as (
         mock_log,
         mock_update_job,
     ):
         setup_chronos_job.bounce_chronos_job(
             service=self.fake_service,
             instance=self.fake_instance,
             cluster=self.fake_cluster,
             job_to_update=None,
             client=self.fake_client,
         )
         assert not mock_log.called
         assert not mock_update_job.called