def test_cancel_update_api_level(self): """Test kill client-side API logic.""" mock_options = self.setup_mock_options() mock_config = Mock() mock_config.hooks = [] mock_config.raw.return_value.enable_hooks.return_value.get.return_value = False (mock_api, mock_scheduler) = self.setup_mock_api() mock_scheduler.releaseLock.return_value = self.get_release_lock_response() with contextlib.nested( patch('twitter.aurora.client.api.SchedulerProxy', return_value=mock_scheduler), patch('twitter.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS), patch('twitter.common.app.get_options', return_value=mock_options), patch('twitter.aurora.client.commands.core.get_job_config', return_value=mock_config)) as ( mock_scheduler_proxy_class, mock_clusters, options, mock_get_job_config): with temporary_file() as fp: fp.write(self.get_valid_config()) fp.flush() cancel_update(['west/mchucarroll/test/hello'], mock_options) # All that cancel_update really does is release the update lock. # So that's all we really need to check. assert mock_scheduler.releaseLock.call_count == 1 assert mock_scheduler.releaseLock.call_args[0][0].key.job == JobKey(environment='test', role='mchucarroll', name='hello')
def test_cancel_update_api_level(self): """Test kill client-side API logic.""" mock_options = self.setup_mock_options() mock_config = Mock() mock_config.hooks = [] mock_config.raw.return_value.enable_hooks.return_value.get.return_value = False (mock_api, mock_scheduler) = self.setup_mock_api() mock_scheduler.releaseLock.return_value = self.get_release_lock_response( ) with contextlib.nested( patch('twitter.aurora.client.api.SchedulerProxy', return_value=mock_scheduler), patch('twitter.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS), patch('twitter.common.app.get_options', return_value=mock_options), patch( 'twitter.aurora.client.commands.core.get_job_config', return_value=mock_config)) as (mock_scheduler_proxy_class, mock_clusters, options, mock_get_job_config): with temporary_file() as fp: fp.write(self.get_valid_config()) fp.flush() cancel_update(['west/mchucarroll/test/hello'], mock_options) # All that cancel_update really does is release the update lock. # So that's all we really need to check. assert mock_scheduler.releaseLock.call_count == 1 assert mock_scheduler.releaseLock.call_args[0][ 0].key.job == JobKey(environment='test', role='mchucarroll', name='hello')
def test_simple_successful_cancel_update(self): """Run a test of the "kill" command against a mocked-out API: Verifies that the kill command sends the right API RPCs, and performs the correct tests on the result.""" mock_options = self.setup_mock_options() mock_config = Mock() mock_api_factory = self.setup_mock_api_factory() with contextlib.nested( patch('twitter.aurora.client.commands.core.make_client_factory', return_value=mock_api_factory), patch('twitter.common.app.get_options', return_value=mock_options), patch('twitter.aurora.client.commands.core.get_job_config', return_value=mock_config)) as ( mock_make_client_factory, options, mock_get_job_config): mock_api = mock_api_factory.return_value cancel_update(['west/mchucarroll/test/hello'], mock_options) self.assert_cancel_update_called(mock_api)
def test_simple_successful_cancel_update(self): """Run a test of the "kill" command against a mocked-out API: Verifies that the kill command sends the right API RPCs, and performs the correct tests on the result.""" mock_options = self.setup_mock_options() mock_config = Mock() mock_api_factory = self.setup_mock_api_factory() with contextlib.nested( patch( 'twitter.aurora.client.commands.core.make_client_factory', return_value=mock_api_factory), patch('twitter.common.app.get_options', return_value=mock_options), patch('twitter.aurora.client.commands.core.get_job_config', return_value=mock_config)) as (mock_make_client_factory, options, mock_get_job_config): mock_api = mock_api_factory.return_value cancel_update(['west/mchucarroll/test/hello'], mock_options) self.assert_cancel_update_called(mock_api)