def test_filter_by_goal_name(self): goal1 = obj_utils.create_test_goal( self.context, id=1, uuid=utils.generate_uuid(), name='My_Goal 1') goal2 = obj_utils.create_test_goal( self.context, id=2, uuid=utils.generate_uuid(), name='My Goal 2') for id_ in range(1, 3): obj_utils.create_test_strategy( self.context, id=id_, uuid=utils.generate_uuid(), goal_id=goal1['id']) for id_ in range(3, 5): obj_utils.create_test_strategy( self.context, id=id_, uuid=utils.generate_uuid(), goal_id=goal2['id']) response = self.get_json('/strategies/?goal=%s' % goal1['name']) strategies = response['strategies'] self.assertEqual(2, len(strategies)) for strategy in strategies: self.assertEqual(goal1['uuid'], strategy['goal_uuid'])
def test_execute_force_dummy(self): obj_utils.create_test_goal(self.context, id=50, uuid=utils.generate_uuid(), name="my_goal") strategy = obj_utils.create_test_strategy(self.context, id=42, uuid=utils.generate_uuid(), name="dummy") audit_template = obj_utils.create_test_audit_template( self.context, uuid=utils.generate_uuid(), strategy_id=strategy.id, name="my_template") audit = obj_utils.create_test_audit( self.context, audit_template_id=audit_template.id, uuid=utils.generate_uuid(), ) solution = self.strategy_context.execute_strategy( audit.uuid, self.context) self.assertEqual(len(solution.actions), 3)
def setUp(self): super(TestStrategyContext, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="DUMMY") audit_template = obj_utils.create_test_audit_template( self.context, uuid=utils.generate_uuid()) self.audit = obj_utils.create_test_audit( self.context, audit_template_id=audit_template.id)
def test_execute_force_basic(self, mock_call): expected_strategy = "basic" mock_call.return_value = expected_strategy obj_utils.create_test_goal(self.context, id=50, uuid=utils.generate_uuid(), name="my_goal") strategy = obj_utils.create_test_strategy(self.context, id=42, uuid=utils.generate_uuid(), name=expected_strategy) audit_template = obj_utils.create_test_audit_template( self.context, uuid=utils.generate_uuid(), strategy_id=strategy.id, name="my_template") audit = obj_utils.create_test_audit( self.context, audit_template_id=audit_template.id, uuid=utils.generate_uuid(), ) solution = self.strategy_context.execute_strategy( audit.uuid, self.context) self.assertEqual(solution, expected_strategy)
def test_goals_collection_links(self): for idx in range(1, 6): obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) response = self.get_json('/goals/?limit=2') self.assertEqual(2, len(response['goals']))
def setUp(self): super(TestDefaultAuditHandler, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="dummy") audit_template = obj_utils.create_test_audit_template( self.context) self.audit = obj_utils.create_test_audit( self.context, audit_template_id=audit_template.id)
def setUp(self): super(TestPost, self).setUp() obj_utils.create_test_audit_template(self.context) obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) p = mock.patch.object(db_api.BaseConnection, 'create_audit') self.mock_create_audit = p.start() self.mock_create_audit.side_effect = (self._simulate_rpc_audit_create) self.addCleanup(p.stop)
def test_goals_collection_links_default_limit(self): for idx in range(1, 6): obj_utils.create_test_goal(self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True) response = self.get_json('/goals') self.assertEqual(3, len(response['goals']))
def test_goals_collection_links_default_limit(self): for idx in range(1, 6): obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True) response = self.get_json('/goals') self.assertEqual(3, len(response['goals']))
def test_detail(self): obj_utils.create_test_goal(self.context) strategy = obj_utils.create_test_strategy(self.context) response = self.get_json('/strategies/detail') self.assertEqual(strategy.uuid, response['strategies'][0]["uuid"]) self._assert_strategy_fields(response['strategies'][0]) for strategy in response['strategies']: self.assertTrue( all(val is not None for key, val in strategy.items() if key in ['uuid', 'name', 'display_name', 'goal_uuid']))
def setUp(self): super(TestDelete, self).setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) self.audit = obj_utils.create_test_audit(self.context) p = mock.patch.object(db_api.BaseConnection, 'update_audit') self.mock_audit_update = p.start() self.mock_audit_update.side_effect = self._simulate_rpc_audit_update self.addCleanup(p.stop)
def setUp(self): super(TestTaskFlowActionContainer, self).setUp() self.engine = tflow.DefaultWorkFlowEngine( config=mock.Mock(), context=self.context, applier_manager=mock.MagicMock()) obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context) self.audit = obj_utils.create_test_audit(self.context, strategy_id=self.strategy.id)
def setUp(self): super(TestContinuousAuditHandler, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="DUMMY") audit_template = obj_utils.create_test_audit_template( self.context) self.audits = [obj_utils.create_test_audit( self.context, uuid=uuid.uuid4(), audit_template_id=audit_template.id, audit_type=audit_objects.AuditType.CONTINUOUS.value) for i in range(2)]
def test_detail(self): obj_utils.create_test_goal(self.context) scoring_engine = obj_utils.create_test_scoring_engine(self.context) response = self.get_json('/scoring_engines/detail') self.assertEqual( scoring_engine.name, response['scoring_engines'][0]['name']) self._assert_scoring_engine_fields(response['scoring_engines'][0]) for scoring_engine in response['scoring_engines']: self.assertTrue( all(val is not None for key, val in scoring_engine.items() if key in ['uuid', 'name', 'description', 'metainfo']))
def setUp(self): super(TestOneShotAuditHandler, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="dummy") self.strategy = obj_utils.create_test_strategy(self.context, name='dummy') audit_template = obj_utils.create_test_audit_template( self.context, strategy_id=self.strategy.id) self.audit = obj_utils.create_test_audit( self.context, strategy_id=self.strategy.id, audit_template_id=audit_template.id)
def setUp(self): super(TestDelete, self).setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) self.action_plan = obj_utils.create_test_action_plan(self.context) p = mock.patch.object(db_api.BaseConnection, 'destroy_action_plan') self.mock_action_plan_delete = p.start() self.mock_action_plan_delete.side_effect = \ self._simulate_rpc_action_plan_delete self.addCleanup(p.stop)
def setUp(self): super(TestPatch, self).setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) obj_utils.create_test_action_plan(self.context) self.action = obj_utils.create_test_action(self.context, parents=None) p = mock.patch.object(db_api.BaseConnection, 'update_action') self.mock_action_update = p.start() self.mock_action_update.side_effect = self._simulate_rpc_action_update self.addCleanup(p.stop)
def test_detail(self): obj_utils.create_test_goal(self.context) scoring_engine = obj_utils.create_test_scoring_engine(self.context) response = self.get_json('/scoring_engines/detail') self.assertEqual(scoring_engine.name, response['scoring_engines'][0]['name']) self._assert_scoring_engine_fields(response['scoring_engines'][0]) for scoring_engine in response['scoring_engines']: self.assertTrue( all(val is not None for key, val in scoring_engine.items() if key in ['uuid', 'name', 'description', 'metainfo']))
def setUp(self): super(TestContinuousAuditHandler, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="dummy") audit_template = obj_utils.create_test_audit_template(self.context) self.audits = [ obj_utils.create_test_audit( self.context, uuid=uuid.uuid4(), audit_template_id=audit_template.id, audit_type=audit_objects.AuditType.CONTINUOUS.value) for i in range(2) ]
def test_policy_disallow_update(self): obj_utils.create_test_goal(self.context) audit_template = obj_utils.create_test_audit_template(self.context) self._common_policy_check("audit_template:update", self.patch_json, '/audit_templates/%s' % audit_template.uuid, [{ 'path': '/state', 'value': objects.audit.State.SUCCEEDED, 'op': 'replace' }], expect_errors=True)
def setUp(self): super(TestStart, self).setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) self.action_plan = obj_utils.create_test_action_plan( self.context, state=objects.action_plan.State.RECOMMENDED) p = mock.patch.object(db_api.BaseConnection, 'update_action_plan') self.mock_action_plan_update = p.start() self.mock_action_plan_update.side_effect = \ self._simulate_rpc_action_plan_update self.addCleanup(p.stop)
def setUp(self): super(FunctionalTestWithSetup, self).setUp() self.fake_goal1 = obj_utils.create_test_goal( self.context, id=1, uuid=utils.generate_uuid(), name="dummy_1") self.fake_goal2 = obj_utils.create_test_goal( self.context, id=2, uuid=utils.generate_uuid(), name="dummy_2") self.fake_strategy1 = obj_utils.create_test_strategy( self.context, id=1, uuid=utils.generate_uuid(), name="strategy_1", goal_id=self.fake_goal1.id) self.fake_strategy2 = obj_utils.create_test_strategy( self.context, id=2, uuid=utils.generate_uuid(), name="strategy_2", goal_id=self.fake_goal2.id)
def setUp(self): super(TestDefaultActionPlanHandler, self).setUp() p_action_plan_notifications = mock.patch.object(notifications, 'action_plan', autospec=True) self.m_action_plan_notifications = p_action_plan_notifications.start() self.addCleanup(p_action_plan_notifications.stop) obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) self.action_plan = obj_utils.create_test_action_plan(self.context)
def test_many(self): obj_utils.create_test_goal(self.context) strategy_list = [] for idx in range(1, 6): strategy = obj_utils.create_test_strategy( self.context, id=idx, uuid=utils.generate_uuid(), name='STRATEGY_{0}'.format(idx)) strategy_list.append(strategy.uuid) response = self.get_json('/strategies') self.assertEqual(5, len(response['strategies'])) for strategy in response['strategies']: self.assertTrue( all(val is not None for key, val in strategy.items() if key in ['uuid', 'name', 'display_name', 'goal_uuid']))
def setUp(self): super(TestStrategyContext, self).setUp() obj_utils.create_test_goal(self.context, id=1, name="DUMMY") audit_template = obj_utils.create_test_audit_template( self.context, uuid=utils.generate_uuid()) self.audit = obj_utils.create_test_audit( self.context, audit_template_id=audit_template.id) self.fake_cluster = faker_cluster_state.FakerModelCollector() p_model = mock.patch.object( strategies.DummyStrategy, "compute_model", new_callable=mock.PropertyMock) self.m_model = p_model.start() self.addCleanup(p_model.stop) self.m_model.return_value = self.fake_cluster.build_scenario_1()
def setUp(self): super(TestDefaultPlanner, self).setUp() self.planner = pbase.WorkloadStabilizationPlanner(mock.Mock()) self.planner.config.weights = { 'nop': 0, 'sleep': 1, 'change_nova_service_state': 2, 'migrate': 3 } self.goal = obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context, goal_id=self.goal.id) obj_utils.create_test_audit_template(self.context, goal_id=self.goal.id, strategy_id=self.strategy.id) p = mock.patch.object(db_api.BaseConnection, 'create_action_plan') self.mock_create_action_plan = p.start() self.mock_create_action_plan.side_effect = ( self._simulate_action_plan_create) self.addCleanup(p.stop) q = mock.patch.object(db_api.BaseConnection, 'create_action') self.mock_create_action = q.start() self.mock_create_action.side_effect = (self._simulate_action_create) self.addCleanup(q.stop)
def setUp(self): super(TestCancelOngoingActionPlans, self).setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() self.addCleanup(p_audit_notifications.stop) self.goal = obj_utils.create_test_goal( self.context, id=1, name=dummy_strategy.DummyStrategy.get_name()) self.strategy = obj_utils.create_test_strategy( self.context, name=dummy_strategy.DummyStrategy.get_name(), goal_id=self.goal.id) audit_template = obj_utils.create_test_audit_template( self.context, strategy_id=self.strategy.id) self.audit = obj_utils.create_test_audit( self.context, id=999, name='My Audit 999', uuid=uuidutils.generate_uuid(), audit_template_id=audit_template.id, goal_id=self.goal.id, audit_type=objects.audit.AuditType.ONESHOT.value, goal=self.goal, hostname='hostname1', state=objects.audit.State.ONGOING) self.actionplan = obj_utils.create_test_action_plan( self.context, state=objects.action_plan.State.ONGOING, audit_id=999, hostname='hostname1') self.action = obj_utils.create_test_action( self.context, action_plan_id=1, state=objects.action.State.PENDING) cfg.CONF.set_override("host", "hostname1")
def setUp(self): super(TestAuditEndpoint, self).setUp() self.goal = obj_utils.create_test_goal(self.context) self.audit_template = obj_utils.create_test_audit_template( self.context) self.audit = obj_utils.create_test_audit( self.context, audit_template_id=self.audit_template.id)
def test_many_without_soft_deleted(self): goal_list = [] for id_ in [1, 2, 3]: goal = obj_utils.create_test_goal( self.context, id=id_, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(id_)) goal_list.append(goal.uuid) for id_ in [4, 5]: goal = obj_utils.create_test_goal( self.context, id=id_, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(id_)) goal.soft_delete() response = self.get_json('/goals') self.assertEqual(3, len(response['goals'])) uuids = [s['uuid'] for s in response['goals']] self.assertEqual(sorted(goal_list), sorted(uuids))
def setUp(self): super(TestAutoTriggerActionPlan, self).setUp() self.goal = obj_utils.create_test_goal( self.context, id=1, name=dummy_strategy.DummyStrategy.get_name()) self.strategy = obj_utils.create_test_strategy( self.context, name=dummy_strategy.DummyStrategy.get_name(), goal_id=self.goal.id) audit_template = obj_utils.create_test_audit_template(self.context) self.audit = obj_utils.create_test_audit( self.context, id=0, uuid=uuidutils.generate_uuid(), audit_template_id=audit_template.id, goal_id=self.goal.id, audit_type=objects.audit.AuditType.CONTINUOUS.value, goal=self.goal, auto_trigger=True) self.ongoing_action_plan = obj_utils.create_test_action_plan( self.context, uuid=uuidutils.generate_uuid(), audit_id=self.audit.id, strategy_id=self.strategy.id, audit=self.audit, strategy=self.strategy, ) self.recommended_action_plan = obj_utils.create_test_action_plan( self.context, uuid=uuidutils.generate_uuid(), state=objects.action_plan.State.ONGOING, audit_id=self.audit.id, strategy_id=self.strategy.id, audit=self.audit, strategy=self.strategy, )
def test_execute_with_action_plan_cancel(self, m_get_actionplan): obj_utils.create_test_goal(self.context) strategy = obj_utils.create_test_strategy(self.context) audit = obj_utils.create_test_audit(self.context, strategy_id=strategy.id) action_plan = obj_utils.create_test_action_plan( self.context, audit_id=audit.id, strategy_id=strategy.id, state=objects.action_plan.State.CANCELLING) action1 = obj_utils.create_test_action( self.context, action_plan_id=action_plan.id, action_type='nop', state=objects.action.State.SUCCEEDED, input_parameters={'message': 'hello World'}) action2 = obj_utils.create_test_action( self.context, action_plan_id=action_plan.id, action_type='nop', state=objects.action.State.ONGOING, uuid='9eb51e14-936d-4d12-a500-6ba0f5e0bb1c', input_parameters={'message': 'hello World'}) action3 = obj_utils.create_test_action( self.context, action_plan_id=action_plan.id, action_type='nop', state=objects.action.State.PENDING, uuid='bc7eee5c-4fbe-4def-9744-b539be55aa19', input_parameters={'message': 'hello World'}) m_get_actionplan.return_value = action_plan actions = [] actions.append(action1) actions.append(action2) actions.append(action3) self.assertRaises(exception.ActionPlanCancelled, self.engine.execute, actions) try: self.check_action_state(action1, objects.action.State.SUCCEEDED) self.check_action_state(action2, objects.action.State.CANCELLED) self.check_action_state(action3, objects.action.State.CANCELLED) except Exception as exc: self.fail(exc)
def test_many(self): goal_list = [] for idx in range(1, 6): goal = obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) goal_list.append(goal.uuid) response = self.get_json('/goals') self.assertTrue(len(response['goals']) > 2)
def test_many(self): goal_list = [] for idx in range(1, 6): goal = obj_utils.create_test_goal(self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) goal_list.append(goal.uuid) response = self.get_json('/goals') self.assertGreater(len(response['goals']), 2)
def setUp(self): super(TestDefaultActionPlanHandler, self).setUp() p_action_plan_notifications = mock.patch.object( notifications, 'action_plan', autospec=True) self.m_action_plan_notifications = p_action_plan_notifications.start() self.addCleanup(p_action_plan_notifications.stop) obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context) self.audit = obj_utils.create_test_audit( self.context, strategy_id=self.strategy.id) self.action_plan = obj_utils.create_test_action_plan( self.context, audit_id=self.audit.id, strategy_id=self.strategy.id) self.action = obj_utils.create_test_action( self.context, action_plan_id=self.action_plan.id, action_type='nop', input_parameters={'message': 'hello World'})
def test_execute_force_dummy(self): obj_utils.create_test_goal(self.context, id=50, uuid=utils.generate_uuid(), name="my_goal") strategy = obj_utils.create_test_strategy(self.context, id=42, uuid=utils.generate_uuid(), name="dummy") audit = obj_utils.create_test_audit( self.context, strategy_id=strategy.id, uuid=utils.generate_uuid(), ) solution = self.strategy_context.execute_strategy(audit, self.context) self.assertEqual(len(solution.actions), 3)
def test_get_one_soft_deleted(self): goal = obj_utils.create_test_goal(self.context) goal.soft_delete() response = self.get_json('/goals/%s' % goal['uuid'], headers={'X-Show-Deleted': 'True'}) self.assertEqual(goal.uuid, response['uuid']) self._assert_goal_fields(response) response = self.get_json('/goals/%s' % goal['uuid'], expect_errors=True) self.assertEqual(404, response.status_int)
def test_get_one_soft_deleted(self): goal = obj_utils.create_test_goal(self.context) goal.soft_delete() response = self.get_json( '/goals/%s' % goal['uuid'], headers={'X-Show-Deleted': 'True'}) self.assertEqual(goal.uuid, response['uuid']) self._assert_goal_fields(response) response = self.get_json( '/goals/%s' % goal['uuid'], expect_errors=True) self.assertEqual(404, response.status_int)
def test_execute_force_basic(self, mock_call): expected_strategy = "basic" mock_call.return_value = expected_strategy obj_utils.create_test_goal(self.context, id=50, uuid=utils.generate_uuid(), name="my_goal") strategy = obj_utils.create_test_strategy(self.context, id=42, uuid=utils.generate_uuid(), name=expected_strategy) audit = obj_utils.create_test_audit( self.context, strategy_id=strategy.id, uuid=utils.generate_uuid(), ) solution = self.strategy_context.execute_strategy(audit, self.context) self.assertEqual(solution, expected_strategy)
def test_many_with_sort_key_uuid(self): goal_list = [] for idx in range(1, 6): goal = obj_utils.create_test_goal(self.context, id=idx, uuid=utils.generate_uuid(), name='GOAL_{0}'.format(idx)) goal_list.append(goal.uuid) response = self.get_json('/goals/?sort_key=uuid') self.assertEqual(5, len(response['goals'])) uuids = [s['uuid'] for s in response['goals']] self.assertEqual(sorted(goal_list), uuids)
def setUp(self): super(TestAuditNotification, self).setUp() p_get_notifier = mock.patch.object(rpc, 'get_notifier') m_get_notifier = p_get_notifier.start() self.addCleanup(p_get_notifier.stop) self.m_notifier = mock.Mock(spec=om.Notifier) def fake_get_notifier(publisher_id): self.m_notifier.publisher_id = publisher_id return self.m_notifier m_get_notifier.side_effect = fake_get_notifier self.goal = utils.create_test_goal(mock.Mock()) self.strategy = utils.create_test_strategy(mock.Mock())
def setUp(self): super(TestContinuousAuditHandler, self).setUp() self.goal = obj_utils.create_test_goal( self.context, id=1, name=dummy_strategy.DummyStrategy.get_name()) audit_template = obj_utils.create_test_audit_template(self.context) self.audits = [ obj_utils.create_test_audit( self.context, id=id_, uuid=uuidutils.generate_uuid(), audit_template_id=audit_template.id, goal_id=self.goal.id, audit_type=objects.audit.AuditType.CONTINUOUS.value, goal=self.goal) for id_ in range(2, 4) ]
def test_many_with_sort_key_goal_uuid(self): goal_list = [] for id_ in range(5): goal = obj_utils.create_test_goal( self.context, name='gl{0}'.format(id_), uuid=utils.generate_uuid()) obj_utils.create_test_audit( self.context, id=id_, uuid=utils.generate_uuid(), goal_id=goal.id, name='My Audit {0}'.format(id_)) goal_list.append(goal.uuid) response = self.get_json('/audits/?sort_key=goal_uuid') self.assertEqual(5, len(response['audits'])) uuids = [s['goal_uuid'] for s in response['audits']] self.assertEqual(sorted(goal_list), uuids)
def setUp(self): super(TestDefaultPlanner, self).setUp() self.planner = pbase.NodeResourceConsolidationPlanner(mock.Mock()) self.goal = obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context, goal_id=self.goal.id) obj_utils.create_test_audit_template(self.context, goal_id=self.goal.id, strategy_id=self.strategy.id) p = mock.patch.object(db_api.BaseConnection, 'create_action_plan') self.mock_create_action_plan = p.start() self.mock_create_action_plan.side_effect = ( self._simulate_action_plan_create) self.addCleanup(p.stop) q = mock.patch.object(db_api.BaseConnection, 'create_action') self.mock_create_action = q.start() self.mock_create_action.side_effect = (self._simulate_action_create) self.addCleanup(q.stop)
def test_get_one_by_name(self): goal = obj_utils.create_test_goal(self.context) response = self.get_json(urlparse.quote( '/goals/%s' % goal['name'])) self.assertEqual(goal.uuid, response['uuid']) self._assert_goal_fields(response)
def _data_setup(self): # All the 1's are soft_deleted and are expired # All the 2's are soft_deleted but are not expired # All the 3's are *not* soft_deleted # Number of days we want to keep in DB (no purge for them) self.cmd.age_in_days = 10 self.cmd.max_number = None self.cmd.orphans = True goal1_name = "GOAL_1" goal2_name = "GOAL_2" goal3_name = "GOAL_3" strategy1_name = "strategy_1" strategy2_name = "strategy_2" strategy3_name = "strategy_3" self.audit_template1_name = self.generate_unique_name( prefix="Audit Template 1 ") self.audit_template2_name = self.generate_unique_name( prefix="Audit Template 2 ") self.audit_template3_name = self.generate_unique_name( prefix="Audit Template 3 ") with freezegun.freeze_time(self.expired_date): self.goal1 = obj_utils.create_test_goal( self.context, id=self._generate_id(), uuid=None, name=goal1_name, display_name=goal1_name.lower()) self.goal2 = obj_utils.create_test_goal( self.context, id=self._generate_id(), uuid=None, name=goal2_name, display_name=goal2_name.lower()) self.goal3 = obj_utils.create_test_goal( self.context, id=self._generate_id(), uuid=None, name=goal3_name, display_name=goal3_name.lower()) self.goal1.soft_delete() with freezegun.freeze_time(self.expired_date): self.strategy1 = obj_utils.create_test_strategy( self.context, id=self._generate_id(), uuid=None, name=strategy1_name, display_name=strategy1_name.lower(), goal_id=self.goal1.id) self.strategy2 = obj_utils.create_test_strategy( self.context, id=self._generate_id(), uuid=None, name=strategy2_name, display_name=strategy2_name.lower(), goal_id=self.goal2.id) self.strategy3 = obj_utils.create_test_strategy( self.context, id=self._generate_id(), uuid=None, name=strategy3_name, display_name=strategy3_name.lower(), goal_id=self.goal3.id) self.strategy1.soft_delete() with freezegun.freeze_time(self.expired_date): self.audit_template1 = obj_utils.create_test_audit_template( self.context, name=self.audit_template1_name, id=self._generate_id(), uuid=None, goal_id=self.goal1.id, strategy_id=self.strategy1.id) self.audit_template2 = obj_utils.create_test_audit_template( self.context, name=self.audit_template2_name, id=self._generate_id(), uuid=None, goal_id=self.goal2.id, strategy_id=self.strategy2.id) self.audit_template3 = obj_utils.create_test_audit_template( self.context, name=self.audit_template3_name, id=self._generate_id(), uuid=None, goal_id=self.goal3.id, strategy_id=self.strategy3.id) self.audit_template1.soft_delete() with freezegun.freeze_time(self.expired_date): self.audit1 = obj_utils.create_test_audit( self.context, audit_template_id=self.audit_template1.id, id=self._generate_id(), uuid=None) self.audit2 = obj_utils.create_test_audit( self.context, audit_template_id=self.audit_template2.id, id=self._generate_id(), uuid=None) self.audit3 = obj_utils.create_test_audit( self.context, audit_template_id=self.audit_template3.id, id=self._generate_id(), uuid=None) self.audit1.soft_delete() with freezegun.freeze_time(self.expired_date): self.action_plan1 = obj_utils.create_test_action_plan( self.context, audit_id=self.audit1.id, id=self._generate_id(), uuid=None) self.action_plan2 = obj_utils.create_test_action_plan( self.context, audit_id=self.audit2.id, id=self._generate_id(), uuid=None) self.action_plan3 = obj_utils.create_test_action_plan( self.context, audit_id=self.audit3.id, id=self._generate_id(), uuid=None) self.action1 = obj_utils.create_test_action( self.context, action_plan_id=self.action_plan1.id, id=self._generate_id(), uuid=None) self.action2 = obj_utils.create_test_action( self.context, action_plan_id=self.action_plan2.id, id=self._generate_id(), uuid=None) self.action3 = obj_utils.create_test_action( self.context, action_plan_id=self.action_plan3.id, id=self._generate_id(), uuid=None) self.action_plan1.soft_delete()
def test_policy_disallow_get_one(self): goal = obj_utils.create_test_goal(self.context) self._common_policy_check( "goal:get", self.get_json, '/goals/%s' % goal.uuid, expect_errors=True)
def test_get_one_by_uuid(self): goal = obj_utils.create_test_goal(self.context) response = self.get_json('/goals/%s' % goal.uuid) self.assertEqual(goal.uuid, response["uuid"]) self.assertEqual(goal.name, response["name"]) self._assert_goal_fields(response)
def test_detail(self): goal = obj_utils.create_test_goal(self.context) response = self.get_json('/goals/detail') self.assertEqual(goal.uuid, response['goals'][0]["uuid"]) self._assert_goal_fields(response['goals'][0])
def test_detail_against_single(self): goal = obj_utils.create_test_goal(self.context) response = self.get_json('/goals/%s/detail' % goal.uuid, expect_errors=True) self.assertEqual(404, response.status_int)