def test_collection_links(self): for id_ in range(5): obj_utils.create_test_node(self.context, id=id_, uuid=utils.generate_uuid()) response = self.get_json('/nodes/?limit=3') self.assertEqual(3, len(response['nodes'])) next_marker = response['nodes'][-1]['uuid'] self.assertIn(next_marker, response['next'])
def test_collection_links_default_limit(self): cfg.CONF.set_override('max_limit', 3, 'api') for id_ in range(5): obj_utils.create_test_node(self.context, id=id_, uuid=utils.generate_uuid()) response = self.get_json('/nodes') self.assertEqual(3, len(response['nodes'])) next_marker = response['nodes'][-1]['uuid'] self.assertIn(next_marker, response['next'])
def test_links(self): uuid = utils.generate_uuid() obj_utils.create_test_node(self.context, id=1, uuid=uuid) response = self.get_json('/nodes/%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))
def test_policy_disallow_delete(self): node = obj_utils.create_test_node(self.context, uuid=utils.generate_uuid()) self._common_policy_check("node:delete", self.delete, '/nodes/%s' % node.uuid, expect_errors=True)
def test_policy_disallow_update(self): node = obj_utils.create_test_node(self.context, type='type_A', uuid="333-444-5555") self._common_policy_check( "node:update", self.patch_json, '/nodes/%s' % node.uuid, [{'type': '/type', 'value': "new_type", 'op': 'replace'}])
def test_many(self): node_list = [] for id_ in range(5): node = obj_utils.create_test_node(self.context, id=id_, uuid=utils.generate_uuid()) node_list.append(node.uuid) response = self.get_json('/nodes') self.assertEqual(len(node_list), len(response['nodes'])) uuids = [s['uuid'] for s in response['nodes']] self.assertEqual(sorted(node_list), sorted(uuids))
def test_get_all_with_pagination_marker(self): node_list = [] for id_ in range(4): node = obj_utils.create_test_node(self.context, id=id_, uuid=utils.generate_uuid()) node_list.append(node.uuid) response = self.get_json('/nodes?limit=3&marker=%s' % node_list[2]) self.assertEqual(1, len(response['nodes'])) self.assertEqual(node_list[-1], response['nodes'][0]['uuid'])
def test_policy_disallow_update(self): node = obj_utils.create_test_node(self.context, type='type_A', uuid=utils.generate_uuid()) self._common_policy_check("node:update", self.patch_json, '/nodes/%s' % node.uuid, [{ 'path': '/type', 'value': "new_type", 'op': 'replace' }], expect_errors=True)
def test_detail_against_single(self): node = obj_utils.create_test_node(self.context) response = self.get_json('/nodes/%s/detail' % node['uuid'], expect_errors=True) self.assertEqual(404, response.status_int)
def test_detail(self): node = obj_utils.create_test_node(self.context) response = self.get_json('/nodes/detail') self.assertEqual(node.uuid, response['nodes'][0]["uuid"]) self._assert_node_fields(response['nodes'][0])
def test_get_one(self): node = obj_utils.create_test_node(self.context) response = self.get_json('/nodes/%s' % node['uuid']) self.assertEqual(node.uuid, response['uuid']) self._assert_node_fields(response)
def test_policy_disallow_delete(self): node = obj_utils.create_test_node(self.context, uuid='137-246-789') self._common_policy_check( "node:delete", self.delete, '/nodes/%s' % node.uuid)
def setUp(self): super(TestDelete, self).setUp() self.node = obj_utils.create_test_node(self.context, image_id='Fedora')