예제 #1
0
    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_action_plan_without_audit(
                self.context, id=id_, uuid=utils.generate_uuid())
        response = self.get_json('/action_plans/?limit=3')
        self.assertEqual(3, len(response['action_plans']))

        next_marker = response['action_plans'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
예제 #2
0
    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_action_plan_without_audit(
                self.context, id=id_, uuid=utils.generate_uuid())
        response = self.get_json('/action_plans/?limit=3')
        self.assertEqual(3, len(response['action_plans']))

        next_marker = response['action_plans'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
예제 #3
0
 def test_links(self):
     uuid = utils.generate_uuid()
     obj_utils.create_action_plan_without_audit(self.context,
                                                id=1, uuid=uuid)
     response = self.get_json('/action_plans/%s' % uuid)
     self.assertIn('links', response.keys())
     self.assertEqual(2, len(response['links']))
     self.assertIn(uuid, response['links'][0]['href'])
     for l in response['links']:
         bookmark = l['rel'] == 'bookmark'
         self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
예제 #4
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api',
                              enforce_type=True)
        for id_ in range(5):
            obj_utils.create_action_plan_without_audit(
                self.context, id=id_, uuid=utils.generate_uuid(),
                audit_id=None)
        response = self.get_json('/action_plans')
        self.assertEqual(3, len(response['action_plans']))

        next_marker = response['action_plans'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
예제 #5
0
 def test_links(self):
     uuid = utils.generate_uuid()
     obj_utils.create_action_plan_without_audit(self.context,
                                                id=1,
                                                uuid=uuid)
     response = self.get_json('/action_plans/%s' % uuid)
     self.assertIn('links', response.keys())
     self.assertEqual(2, len(response['links']))
     self.assertIn(uuid, response['links'][0]['href'])
     for l in response['links']:
         bookmark = l['rel'] == 'bookmark'
         self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
예제 #6
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True)
        for id_ in range(5):
            obj_utils.create_action_plan_without_audit(
                self.context,
                id=id_,
                uuid=utils.generate_uuid(),
                audit_id=None)
        response = self.get_json('/action_plans')
        self.assertEqual(3, len(response['action_plans']))

        next_marker = response['action_plans'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
예제 #7
0
 def test_many_with_soft_deleted(self):
     action_plan_list = []
     for id_ in [1, 2, 3]:
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan_list.append(action_plan.uuid)
     for id_ in [4, 5]:
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan.soft_delete()
         action_plan_list.append(action_plan.uuid)
     response = self.get_json('/action_plans',
                              headers={'X-Show-Deleted': 'True'})
     self.assertEqual(5, len(response['action_plans']))
     uuids = [s['uuid'] for s in response['action_plans']]
     self.assertEqual(sorted(action_plan_list), sorted(uuids))
예제 #8
0
 def test_many_with_soft_deleted(self):
     action_plan_list = []
     for id_ in [1, 2, 3]:
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan_list.append(action_plan.uuid)
     for id_ in [4, 5]:
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan.soft_delete()
         action_plan_list.append(action_plan.uuid)
     response = self.get_json('/action_plans',
                              headers={'X-Show-Deleted': 'True'})
     self.assertEqual(5, len(response['action_plans']))
     uuids = [s['uuid'] for s in response['action_plans']]
     self.assertEqual(sorted(action_plan_list), sorted(uuids))
예제 #9
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.action_plan = obj_utils.create_action_plan_without_audit(
         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)
예제 #10
0
    def test_replace_state_pending_not_found(self):
        action_plan = obj_utils.create_action_plan_without_audit(
            self.context, state=objects.action_plan.State.DELETED)

        response = self.get_json('/action_plans/%s' % action_plan.uuid,
                                 expect_errors=True)
        self.assertEqual(404, response.status_code)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['error_message'])
예제 #11
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.action_plan = obj_utils.create_action_plan_without_audit(
         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)
예제 #12
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.action_plan = obj_utils.create_action_plan_without_audit(
         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)
예제 #13
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.action_plan = obj_utils.create_action_plan_without_audit(
         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)
예제 #14
0
 def test_many(self):
     action_plan_list = []
     for id_ in range(5):
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan_list.append(action_plan.uuid)
     response = self.get_json('/action_plans')
     self.assertEqual(len(action_plan_list), len(response['action_plans']))
     uuids = [s['uuid'] for s in response['action_plans']]
     self.assertEqual(sorted(action_plan_list), sorted(uuids))
예제 #15
0
    def test_one_soft_deleted(self):
        action_plan = obj_utils.create_action_plan_without_audit(self.context)
        action_plan.soft_delete()
        response = self.get_json('/action_plans',
                                 headers={'X-Show-Deleted': 'True'})
        self.assertEqual(action_plan.uuid, response['action_plans'][0]["uuid"])
        self._assert_action_plans_fields(response['action_plans'][0])

        response = self.get_json('/action_plans')
        self.assertEqual([], response['action_plans'])
예제 #16
0
 def test_many(self):
     action_plan_list = []
     for id_ in range(5):
         action_plan = obj_utils.create_action_plan_without_audit(
             self.context, id=id_, uuid=utils.generate_uuid())
         action_plan_list.append(action_plan.uuid)
     response = self.get_json('/action_plans')
     self.assertEqual(len(action_plan_list), len(response['action_plans']))
     uuids = [s['uuid'] for s in response['action_plans']]
     self.assertEqual(sorted(action_plan_list), sorted(uuids))
예제 #17
0
    def test_one_soft_deleted(self):
        action_plan = obj_utils.create_action_plan_without_audit(self.context)
        action_plan.soft_delete()
        response = self.get_json('/action_plans',
                                 headers={'X-Show-Deleted': 'True'})
        self.assertEqual(action_plan.uuid,
                         response['action_plans'][0]["uuid"])
        self._assert_action_plans_fields(response['action_plans'][0])

        response = self.get_json('/action_plans')
        self.assertEqual([], response['action_plans'])
예제 #18
0
    def test_replace_state_pending_not_found(self):
        action_plan = obj_utils.create_action_plan_without_audit(
            self.context, state=objects.action_plan.State.DELETED)

        response = self.get_json(
            '/action_plans/%s' % action_plan.uuid,
            expect_errors=True
        )
        self.assertEqual(404, response.status_code)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['error_message'])
예제 #19
0
    def test_get_one_soft_deleted(self):
        action_plan = obj_utils.create_action_plan_without_audit(self.context)
        action_plan.soft_delete()
        response = self.get_json('/action_plans/%s' % action_plan['uuid'],
                                 headers={'X-Show-Deleted': 'True'})
        self.assertEqual(action_plan.uuid, response['uuid'])
        self._assert_action_plans_fields(response)

        response = self.get_json('/action_plans/%s' % action_plan['uuid'],
                                 expect_errors=True)
        self.assertEqual(404, response.status_int)
예제 #20
0
    def test_get_one_soft_deleted(self):
        action_plan = obj_utils.create_action_plan_without_audit(self.context)
        action_plan.soft_delete()
        response = self.get_json('/action_plans/%s' % action_plan['uuid'],
                                 headers={'X-Show-Deleted': 'True'})
        self.assertEqual(action_plan.uuid, response['uuid'])
        self._assert_action_plans_fields(response)

        response = self.get_json('/action_plans/%s' % action_plan['uuid'],
                                 expect_errors=True)
        self.assertEqual(404, response.status_int)
예제 #21
0
    def test_replace_state_pending_ok(self):
        action_plan = obj_utils.create_action_plan_without_audit(
            self.context, state=self.original_state)

        initial_ap = self.get_json('/action_plans/%s' % action_plan.uuid)

        response = self.patch_json(
            '/action_plans/%s' % action_plan.uuid,
            [{'path': '/state', 'value': self.new_state,
             'op': 'replace'}])
        updated_ap = self.get_json('/action_plans/%s' % action_plan.uuid)

        self.assertNotEqual(self.new_state, initial_ap['state'])
        self.assertEqual(self.new_state, updated_ap['state'])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(200, response.status_code)
예제 #22
0
    def test_replace_state_pending_ok(self):
        action_plan = obj_utils.create_action_plan_without_audit(
            self.context, state=self.original_state)

        initial_ap = self.get_json('/action_plans/%s' % action_plan.uuid)

        response = self.patch_json('/action_plans/%s' % action_plan.uuid,
                                   [{
                                       'path': '/state',
                                       'value': self.new_state,
                                       'op': 'replace'
                                   }])
        updated_ap = self.get_json('/action_plans/%s' % action_plan.uuid)

        self.assertNotEqual(self.new_state, initial_ap['state'])
        self.assertEqual(self.new_state, updated_ap['state'])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(200, response.status_code)
예제 #23
0
    def test_replace_state_triggered_denied(self):
        action_plan = obj_utils.create_action_plan_without_audit(
            self.context, state=self.original_state)

        initial_ap = self.get_json('/action_plans/%s' % action_plan.uuid)
        response = self.patch_json('/action_plans/%s' % action_plan.uuid,
                                   [{
                                       'path': '/state',
                                       'value': self.new_state,
                                       'op': 'replace'
                                   }],
                                   expect_errors=True)
        updated_ap = self.get_json('/action_plans/%s' % action_plan.uuid)

        self.assertNotEqual(self.new_state, initial_ap['state'])
        self.assertEqual(self.original_state, updated_ap['state'])
        self.assertEqual(400, response.status_code)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['error_message'])
예제 #24
0
 def test_get_one_ok(self):
     action_plan = obj_utils.create_action_plan_without_audit(self.context)
     response = self.get_json('/action_plans/%s' % action_plan['uuid'])
     self.assertEqual(action_plan.uuid, response['uuid'])
     self._assert_action_plans_fields(response)
예제 #25
0
 def test_one(self):
     action_plan = obj_utils.create_action_plan_without_audit(self.context)
     response = self.get_json('/action_plans')
     self.assertEqual(action_plan.uuid, response['action_plans'][0]["uuid"])
     self._assert_action_plans_fields(response['action_plans'][0])
예제 #26
0
 def test_one(self):
     action_plan = obj_utils.create_action_plan_without_audit(self.context)
     response = self.get_json('/action_plans')
     self.assertEqual(action_plan.uuid,
                      response['action_plans'][0]["uuid"])
     self._assert_action_plans_fields(response['action_plans'][0])
예제 #27
0
 def test_get_one_ok(self):
     action_plan = obj_utils.create_action_plan_without_audit(self.context)
     response = self.get_json('/action_plans/%s' % action_plan['uuid'])
     self.assertEqual(action_plan.uuid, response['uuid'])
     self._assert_action_plans_fields(response)