def test_do_action_plan_list_by_table(self): action_plan1 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) action_plan2 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_2) self.m_action_plan_mgr.list.return_value = [ action_plan1, action_plan2] exit_code, results = self.run_cmd('actionplan list', 'table') self.assertEqual(0, exit_code) self.assertIn(ACTION_PLAN_1['uuid'], results) self.assertIn(ACTION_PLAN_2['uuid'], results) self.m_action_plan_mgr.list.assert_called_once_with(detail=False)
def test_do_action_plan_list_detail(self): action_plan1 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) action_plan2 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_2) self.m_action_plan_mgr.list.return_value = [ action_plan1, action_plan2] exit_code, results = self.run_cmd('actionplan list --detail') self.assertEqual(0, exit_code) self.assertEqual( [self.resource_as_dict(action_plan1, self.FIELDS, self.FIELD_LABELS), self.resource_as_dict(action_plan2, self.FIELDS, self.FIELD_LABELS)], results) self.m_action_plan_mgr.list.assert_called_once_with(detail=True)
def test_do_action_plan_list(self): action_plan1 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) action_plan2 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_2) self.m_action_plan_mgr.list.return_value = [ action_plan1, action_plan2] exit_code, results = self.run_cmd('actionplan list') self.assertEqual(0, exit_code) self.assertEqual( [self.resource_as_dict(action_plan1, self.SHORT_LIST_FIELDS, self.SHORT_LIST_FIELD_LABELS), self.resource_as_dict(action_plan2, self.SHORT_LIST_FIELDS, self.SHORT_LIST_FIELD_LABELS)], results) self.assertEqual(action_plan1.global_efficacy, results[0]['Global efficacy']) self.assertEqual(action_plan2.global_efficacy, results[1]['Global efficacy'])
def test_do_action_plan_cancel(self): action_plan = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) self.m_action_plan_mgr.cancel.return_value = action_plan exit_code, result = self.run_cmd( 'actionplan cancel 5869da81-4876-4687-a1ed-12cd64cf53d9') self.assertEqual(0, exit_code) self.assertEqual( self.resource_as_dict(action_plan, self.FIELDS, self.FIELD_LABELS), result) self.m_action_plan_mgr.cancel.assert_called_once_with( '5869da81-4876-4687-a1ed-12cd64cf53d9')
def test_do_action_plan_show_uuid_by_table(self): # verify that show an actionplan can be in a 'table' format action_plan = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) self.m_action_plan_mgr.get.return_value = action_plan exit_code, result = self.run_cmd( 'actionplan show d9d9978e-6db5-4a05-8eab-1531795d7004', formatting='table') self.assertEqual(0, exit_code) self.assertIn(ACTION_PLAN_1['uuid'], result) self.m_action_plan_mgr.get.assert_called_once_with( 'd9d9978e-6db5-4a05-8eab-1531795d7004')
def test_do_action_plan_show_by_uuid(self): action_plan = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) self.m_action_plan_mgr.get.return_value = action_plan exit_code, result = self.run_cmd( 'actionplan show d9d9978e-6db5-4a05-8eab-1531795d7004') self.assertEqual(0, exit_code) self.assertEqual( self.resource_as_dict( action_plan, self.FIELDS, self.FIELD_LABELS), result) self.m_action_plan_mgr.get.assert_called_once_with( 'd9d9978e-6db5-4a05-8eab-1531795d7004')
def test_do_action_plan_update(self): action_plan = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) self.m_action_plan_mgr.update.return_value = action_plan exit_code, result = self.run_cmd( 'actionplan update 5869da81-4876-4687-a1ed-12cd64cf53d9 ' 'replace state=CANCELLED') self.assertEqual(0, exit_code) self.assertEqual( self.resource_as_dict(action_plan, self.FIELDS, self.FIELD_LABELS), result) self.m_action_plan_mgr.update.assert_called_once_with( '5869da81-4876-4687-a1ed-12cd64cf53d9', [{'op': 'replace', 'path': '/state', 'value': 'CANCELLED'}])
def test_do_action_plan_list_filter_by_audit(self): action_plan1 = resource.ActionPlan(mock.Mock(), ACTION_PLAN_1) self.m_action_plan_mgr.list.return_value = [action_plan1] exit_code, results = self.run_cmd( 'actionplan list --audit ' '770ef053-ecb3-48b0-85b5-d55a2dbc6588') self.assertEqual(0, exit_code) self.assertEqual( [self.resource_as_dict(action_plan1, self.SHORT_LIST_FIELDS, self.SHORT_LIST_FIELD_LABELS)], results) self.m_action_plan_mgr.list.assert_called_once_with( detail=False, audit='770ef053-ecb3-48b0-85b5-d55a2dbc6588', )