def test_cron_status_multiple_jobs(self): _, mock_scheduler_proxy = self.create_mock_api() with contextlib.nested( patch('time.sleep'), patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy), patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS), patch('apache.aurora.client.cli.context.AuroraCommandContext.print_out')) as ( _, _, _, mock_print): response = self.create_simple_success_response() response.result = Result(getJobsResult=GetJobsResult(configs=[ JobConfiguration( key=JobKey(role='bozo', environment='test', name='hello'), cronSchedule='* * * * *'), JobConfiguration( key=JobKey(role='bozo', environment='test', name='hello2'), cronSchedule='* * * * *') ])) mock_scheduler_proxy.getJobs.return_value = response cmd = AuroraCommandLine() result = cmd.execute(['cron', 'show', 'west/bozo/test/hello']) assert result == EXIT_OK mock_scheduler_proxy.getJobs.assert_called_once_with("bozo") mock_print.assert_called_with("west/bozo/test/hello\t * * * * *")
def _create_getjobs_response(cls): response = cls.create_simple_success_response() response.result = Result(getJobsResult=GetJobsResult(configs=[ JobConfiguration( cronSchedule='* * * * *', key=JobKey(role='bozo', environment='test', name='hello')) ])) return response
def _expect_get_jobs(self, *envs): self._api.get_jobs(self.ROLE).AndReturn( Response(responseCode=ResponseCode.OK, messageDEPRECATED='Mock OK', result=Result(getJobsResult=GetJobsResult(configs=set( JobConfiguration(key=JobKey( role=self.ROLE, environment=env, name=self.NAME)) for env in envs)))))
def create_getjobs_response(cls): mock_job_one = JobConfiguration( key=JobKey(role='RoleA', environment='test', name='hithere')) mock_job_two = JobConfiguration( key=JobKey(role='bozo', environment='test', name='hello')) result = cls.create_simple_success_response() result.result = Result(getJobsResult=GetJobsResult( configs=[mock_job_one, mock_job_two])) return result
def test_cron_status_multiple_jobs(self): mock_context = FakeAuroraCommandContext() with patch('apache.aurora.client.cli.cron.CronNoun.create_context', return_value=mock_context): api = mock_context.get_api("west") response = self.create_simple_success_response() response.result = Result(getJobsResult=GetJobsResult(configs=[ JobConfiguration(key=JobKey( role='bozo', environment='test', name='hello'), cronSchedule='* * * * *'), JobConfiguration(key=JobKey( role='bozo', environment='test', name='hello2'), cronSchedule='* * * * *') ])) api.get_jobs.return_value = response cmd = AuroraCommandLine() result = cmd.execute(['cron', 'show', 'west/bozo/test/hello']) assert result == EXIT_OK api.get_jobs.assert_called_once_with("bozo") assert mock_context.get_out_str( ) == "west/bozo/test/hello\t * * * * *"