def test_get_org_missing(self): config = CliConfig() config.keychain = mock.Mock() config.keychain.get_org.return_value = None with self.assertRaises(click.UsageError): org_name, org_config_result = config.get_org("test", fail_if_missing=True)
def test_get_org_default(self): config = CliConfig() config.keychain = mock.Mock() org_config = OrgConfig({}, "test") config.keychain.get_default_org.return_value = ("test", org_config) org_name, org_config_result = config.get_org() self.assertEqual("test", org_name) self.assertIs(org_config, org_config_result)
def test_flow_run_org_delete_error(self, echo): org_config = mock.Mock(scratch=True, config={}) org_config.delete_org.side_effect = Exception config = CliConfig( config={ "flows": { "test": { "steps": { 1: { "task": "test_task" } } } }, "tasks": { "test_task": { "class_path": "cumulusci.cli.tests.test_cci.DummyTask", "description": "Test Task", } }, }, load_keychain=False, ) config.get_org = mock.Mock(return_value=("test", org_config)) DummyTask._run_task = mock.Mock() run_click_command( cci.flow_run, config=config, flow_name="test", org="test", delete_org=True, debug=False, o=None, skip=(), no_prompt=True, ) echo.assert_any_call( "Scratch org deletion failed. Ignoring the error below to complete the flow:" )
def test_flow_run(self): org_config = mock.Mock(scratch=True, config={}) config = CliConfig( config={ "flows": { "test": { "steps": { 1: { "task": "test_task" } } } }, "tasks": { "test_task": { "class_path": "cumulusci.cli.tests.test_cci.DummyTask", "description": "Test Task", } }, }, load_keychain=False, ) config.get_org = mock.Mock(return_value=("test", org_config)) DummyTask._run_task = mock.Mock() run_click_command( cci.flow_run, config=config, flow_name="test", org="test", delete_org=True, debug=False, o=[("test_task__color", "blue")], skip=(), no_prompt=True, ) DummyTask._run_task.assert_called_once() org_config.delete_org.assert_called_once()
def test_flow_run_unexpected_exception(self, handle_sentry_event): org_config = mock.Mock(config={}) config = CliConfig( config={ "flows": { "test": { "steps": { 1: { "task": "test_task" } } } }, "tasks": { "test_task": { "class_path": "cumulusci.cli.tests.test_cci.DummyTask", "description": "Test Task", } }, }, load_keychain=False, ) config.get_org = mock.Mock(return_value=("test", org_config)) DummyTask._run_task = mock.Mock(side_effect=Exception) with self.assertRaises(Exception): run_click_command( cci.flow_run, config=config, flow_name="test", org="test", delete_org=False, debug=False, o=None, skip=(), no_prompt=True, ) handle_sentry_event.assert_called_once()
def test_flow_run_usage_error(self): org_config = mock.Mock(config={}) config = CliConfig( config={ "flows": { "test": { "steps": { 1: { "task": "test_task" } } } }, "tasks": { "test_task": { "class_path": "cumulusci.cli.tests.test_cci.DummyTask", "description": "Test Task", } }, }, load_keychain=False, ) config.get_org = mock.Mock(return_value=("test", org_config)) DummyTask._run_task = mock.Mock(side_effect=TaskOptionsError) with self.assertRaises(click.UsageError): run_click_command( cci.flow_run, config=config, flow_name="test", org="test", delete_org=False, debug=False, o=None, skip=(), no_prompt=True, )