示例#1
0
 def test_detail_using_query_false_and_fields(self):
     obj_utils.create_test_chassis(self.context)
     data = self.get_json(
         '/chassis?detail=False&fields=description',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertIn('description', data['chassis'][0])
     self.assertNotIn('uuid', data['chassis'][0])
示例#2
0
 def test_detail_using_query_old_version(self):
     obj_utils.create_test_chassis(self.context)
     response = self.get_json(
         '/chassis?detail=True',
         headers={api_base.Version.string: str(api_v1.min_version())},
         expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
示例#3
0
 def test_detail_using_query_false_and_fields(self):
     obj_utils.create_test_chassis(self.context)
     data = self.get_json(
         '/chassis?detail=False&fields=description',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertIn('description', data['chassis'][0])
     self.assertNotIn('uuid', data['chassis'][0])
示例#4
0
 def test_detail_using_query_old_version(self):
     obj_utils.create_test_chassis(self.context)
     response = self.get_json(
         '/chassis?detail=True',
         headers={api_base.Version.string: str(api_v1.min_version())},
         expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
示例#5
0
    def test_collection_links(self):
        for id in range(5):
            obj_utils.create_test_chassis(self.context,
                                          uuid=uuidutils.generate_uuid())
        data = self.get_json('/chassis/?limit=3')
        self.assertEqual(3, len(data['chassis']))

        next_marker = data['chassis'][-1]['uuid']
        self.assertIn(next_marker, data['next'])
示例#6
0
    def test_collection_links(self):
        for id in range(5):
            obj_utils.create_test_chassis(self.context,
                                          uuid=uuidutils.generate_uuid())
        data = self.get_json('/chassis/?limit=3')
        self.assertEqual(3, len(data['chassis']))

        next_marker = data['chassis'][-1]['uuid']
        self.assertIn(next_marker, data['next'])
示例#7
0
 def test_detail_query_false(self):
     obj_utils.create_test_chassis(self.context)
     data1 = self.get_json(
         '/chassis',
         headers={api_base.Version.string: str(api_v1.max_version())})
     data2 = self.get_json(
         '/chassis?detail=False',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertEqual(data1['chassis'], data2['chassis'])
示例#8
0
 def test_detail_query_false(self):
     obj_utils.create_test_chassis(self.context)
     data1 = self.get_json(
         '/chassis',
         headers={api_base.Version.string: str(api_v1.max_version())})
     data2 = self.get_json(
         '/chassis?detail=False',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertEqual(data1['chassis'], data2['chassis'])
示例#9
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api')
        for id_ in range(5):
            obj_utils.create_test_chassis(self.context,
                                          uuid=uuidutils.generate_uuid())
        data = self.get_json('/chassis')
        self.assertEqual(3, len(data['chassis']))

        next_marker = data['chassis'][-1]['uuid']
        self.assertIn(next_marker, data['next'])
示例#10
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api')
        for id_ in range(5):
            obj_utils.create_test_chassis(self.context,
                                          uuid=uuidutils.generate_uuid())
        data = self.get_json('/chassis')
        self.assertEqual(3, len(data['chassis']))

        next_marker = data['chassis'][-1]['uuid']
        self.assertIn(next_marker, data['next'])
示例#11
0
    def test_get_collection_custom_fields(self):
        fields = 'uuid,extra'
        for i in range(3):
            obj_utils.create_test_chassis(
                self.context, uuid=uuidutils.generate_uuid())

        data = self.get_json(
            '/chassis?fields=%s' % fields,
            headers={api_base.Version.string: str(api_v1.max_version())})

        self.assertEqual(3, len(data['chassis']))
        for ch in data['chassis']:
            # We always append "links"
            self.assertItemsEqual(['uuid', 'extra', 'links'], ch)
示例#12
0
    def test_get_collection_custom_fields(self):
        fields = 'uuid,extra'
        for i in range(3):
            obj_utils.create_test_chassis(
                self.context, uuid=uuidutils.generate_uuid())

        data = self.get_json(
            '/chassis?fields=%s' % fields,
            headers={api_base.Version.string: str(api_v1.max_version())})

        self.assertEqual(3, len(data['chassis']))
        for ch in data['chassis']:
            # We always append "links"
            self.assertItemsEqual(['uuid', 'extra', 'links'], ch)
示例#13
0
    def test_collection_links_custom_fields(self):
        fields = 'extra,uuid'
        cfg.CONF.set_override('max_limit', 3, 'api')
        for i in range(5):
            obj_utils.create_test_chassis(self.context,
                                          uuid=uuidutils.generate_uuid())

        data = self.get_json(
            '/chassis?fields=%s' % fields,
            headers={api_base.Version.string: str(api_v1.max_version())})

        self.assertEqual(3, len(data['chassis']))
        next_marker = data['chassis'][-1]['uuid']
        self.assertIn(next_marker, data['next'])
        self.assertIn('fields', data['next'])
示例#14
0
    def test_remove_multi(self):
        extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
        chassis = obj_utils.create_test_chassis(self.context, extra=extra,
                                                description="foobar",
                                                uuid=uuidutils.generate_uuid())

        # Removing one item from the collection
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra/foo2', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        extra.pop("foo2")
        self.assertEqual(extra, result['extra'])

        # Removing the collection
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        self.assertEqual({}, result['extra'])

        # Assert nothing else was changed
        self.assertEqual(chassis.uuid, result['uuid'])
        self.assertEqual(chassis.description, result['description'])
示例#15
0
    def test_remove_multi(self):
        extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
        chassis = obj_utils.create_test_chassis(self.context, extra=extra,
                                                description="foobar",
                                                uuid=uuidutils.generate_uuid())

        # Removing one item from the collection
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra/foo2', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        extra.pop("foo2")
        self.assertEqual(extra, result['extra'])

        # Removing the collection
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        self.assertEqual({}, result['extra'])

        # Assert nothing else was changed
        self.assertEqual(chassis.uuid, result['uuid'])
        self.assertEqual(chassis.description, result['description'])
示例#16
0
 def test_post_nodes_subresource(self):
     chassis = obj_utils.create_test_chassis(self.context)
     ndict = apiutils.node_post_data()
     ndict['chassis_uuid'] = chassis.uuid
     response = self.post_json('/chassis/nodes', ndict,
                               expect_errors=True)
     self.assertEqual(http_client.FORBIDDEN, response.status_int)
示例#17
0
 def test_post_nodes_subresource(self):
     chassis = obj_utils.create_test_chassis(self.context)
     ndict = apiutils.node_post_data()
     ndict['chassis_uuid'] = chassis.uuid
     response = self.post_json('/chassis/nodes', ndict,
                               expect_errors=True)
     self.assertEqual(http_client.FORBIDDEN, response.status_int)
示例#18
0
 def test_get_custom_fields_invalid_api_version(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'uuid,extra'
     response = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.min_version())},
         expect_errors=True)
     self.assertEqual(http_client.NOT_ACCEPTABLE, response.status_int)
示例#19
0
 def test_detail_query(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json(
         '/chassis?detail=True',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertEqual(chassis.uuid, data['chassis'][0]["uuid"])
     self.assertIn('extra', data['chassis'][0])
     self.assertIn('nodes', data['chassis'][0])
示例#20
0
 def test_delete_chassis(self):
     chassis = obj_utils.create_test_chassis(self.context)
     self.delete('/chassis/%s' % chassis.uuid)
     response = self.get_json('/chassis/%s' % chassis.uuid,
                              expect_errors=True)
     self.assertEqual(http_client.NOT_FOUND, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
示例#21
0
 def test_get_custom_fields_invalid_api_version(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'uuid,extra'
     response = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.min_version())},
         expect_errors=True)
     self.assertEqual(http_client.NOT_ACCEPTABLE, response.status_int)
示例#22
0
 def test_detail_query(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json(
         '/chassis?detail=True',
         headers={api_base.Version.string: str(api_v1.max_version())})
     self.assertEqual(chassis.uuid, data['chassis'][0]["uuid"])
     self.assertIn('extra', data['chassis'][0])
     self.assertIn('nodes', data['chassis'][0])
示例#23
0
 def test_get_one_custom_fields(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'extra,description'
     data = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.max_version())})
     # We always append "links"
     self.assertItemsEqual(['description', 'extra', 'links'], data)
示例#24
0
 def test_get_one_custom_fields(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'extra,description'
     data = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.max_version())})
     # We always append "links"
     self.assertItemsEqual(['description', 'extra', 'links'], data)
示例#25
0
 def test_delete_chassis_with_node(self):
     chassis = obj_utils.create_test_chassis(self.context)
     obj_utils.create_test_node(self.context, chassis_id=chassis.id)
     response = self.delete('/chassis/%s' % chassis.uuid,
                            expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     self.assertIn(chassis.uuid, response.json['error_message'])
示例#26
0
 def test_sort_key(self):
     ch_list = []
     for id_ in range(3):
         chassis = obj_utils.create_test_chassis(
             self.context, uuid=uuidutils.generate_uuid())
         ch_list.append(chassis.uuid)
     data = self.get_json('/chassis?sort_key=uuid')
     uuids = [n['uuid'] for n in data['chassis']]
     self.assertEqual(sorted(ch_list), uuids)
示例#27
0
 def test_sort_key(self):
     ch_list = []
     for id_ in range(3):
         chassis = obj_utils.create_test_chassis(
             self.context, uuid=uuidutils.generate_uuid())
         ch_list.append(chassis.uuid)
     data = self.get_json('/chassis?sort_key=uuid')
     uuids = [n['uuid'] for n in data['chassis']]
     self.assertEqual(sorted(ch_list), uuids)
示例#28
0
 def test_get_custom_fields_invalid_fields(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'uuid,spongebob'
     response = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.max_version())},
         expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertIn('spongebob', response.json['error_message'])
示例#29
0
    def _test_links(self, public_url=None):
        cfg.CONF.set_override('public_endpoint', public_url, 'api')
        uuid = uuidutils.generate_uuid()
        obj_utils.create_test_chassis(self.context, uuid=uuid)
        data = self.get_json('/chassis/%s' % uuid)
        self.assertIn('links', data)
        self.assertEqual(2, len(data['links']))
        self.assertIn(uuid, data['links'][0]['href'])
        for l in data['links']:
            bookmark = l['rel'] == 'bookmark'
            self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))

        if public_url is not None:
            expected = [{'href': '%s/v1/chassis/%s' % (public_url, uuid),
                         'rel': 'self'},
                        {'href': '%s/chassis/%s' % (public_url, uuid),
                         'rel': 'bookmark'}]
            for i in expected:
                self.assertIn(i, data['links'])
示例#30
0
    def _test_links(self, public_url=None):
        cfg.CONF.set_override('public_endpoint', public_url, 'api')
        uuid = uuidutils.generate_uuid()
        obj_utils.create_test_chassis(self.context, uuid=uuid)
        data = self.get_json('/chassis/%s' % uuid)
        self.assertIn('links', data)
        self.assertEqual(2, len(data['links']))
        self.assertIn(uuid, data['links'][0]['href'])
        for l in data['links']:
            bookmark = l['rel'] == 'bookmark'
            self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))

        if public_url is not None:
            expected = [{'href': '%s/v1/chassis/%s' % (public_url, uuid),
                         'rel': 'self'},
                        {'href': '%s/chassis/%s' % (public_url, uuid),
                         'rel': 'bookmark'}]
            for i in expected:
                self.assertIn(i, data['links'])
示例#31
0
 def test_get_custom_fields_invalid_fields(self):
     chassis = obj_utils.create_test_chassis(self.context)
     fields = 'uuid,spongebob'
     response = self.get_json(
         '/chassis/%s?fields=%s' % (chassis.uuid, fields),
         headers={api_base.Version.string: str(api_v1.max_version())},
         expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertIn('spongebob', response.json['error_message'])
示例#32
0
 def test_many(self):
     ch_list = []
     for id_ in range(5):
         chassis = obj_utils.create_test_chassis(
             self.context, uuid=uuidutils.generate_uuid())
         ch_list.append(chassis.uuid)
     data = self.get_json('/chassis')
     self.assertEqual(len(ch_list), len(data['chassis']))
     uuids = [n['uuid'] for n in data['chassis']]
     six.assertCountEqual(self, ch_list, uuids)
示例#33
0
 def test_many(self):
     ch_list = []
     for id_ in range(5):
         chassis = obj_utils.create_test_chassis(
             self.context, uuid=uuidutils.generate_uuid())
         ch_list.append(chassis.uuid)
     data = self.get_json('/chassis')
     self.assertEqual(len(ch_list), len(data['chassis']))
     uuids = [n['uuid'] for n in data['chassis']]
     six.assertCountEqual(self, ch_list, uuids)
示例#34
0
    def test_remove_singular(self):
        chassis = obj_utils.create_test_chassis(self.context, extra={'a': 'b'},
                                                uuid=uuidutils.generate_uuid())
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/description', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        self.assertIsNone(result['description'])

        # Assert nothing else was changed
        self.assertEqual(chassis.uuid, result['uuid'])
        self.assertEqual(chassis.extra, result['extra'])
示例#35
0
    def test_remove_singular(self):
        chassis = obj_utils.create_test_chassis(self.context, extra={'a': 'b'},
                                                uuid=uuidutils.generate_uuid())
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/description', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        self.assertIsNone(result['description'])

        # Assert nothing else was changed
        self.assertEqual(chassis.uuid, result['uuid'])
        self.assertEqual(chassis.extra, result['extra'])
示例#36
0
 def test_delete_chassis(self, mock_notify):
     chassis = obj_utils.create_test_chassis(self.context)
     self.delete('/chassis/%s' % chassis.uuid)
     response = self.get_json('/chassis/%s' % chassis.uuid,
                              expect_errors=True)
     self.assertEqual(http_client.NOT_FOUND, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     mock_notify.assert_has_calls([mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.START),
                                   mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.END)])
示例#37
0
 def test_delete_chassis(self, mock_notify):
     chassis = obj_utils.create_test_chassis(self.context)
     self.delete('/chassis/%s' % chassis.uuid)
     response = self.get_json('/chassis/%s' % chassis.uuid,
                              expect_errors=True)
     self.assertEqual(http_client.NOT_FOUND, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     mock_notify.assert_has_calls([mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.START),
                                   mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.END)])
示例#38
0
    def test_replace_multi(self):
        extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
        chassis = obj_utils.create_test_chassis(self.context, extra=extra,
                                                uuid=uuidutils.generate_uuid())
        new_value = 'new value'
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra/foo2',
                                     'value': new_value, 'op': 'replace'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)

        extra["foo2"] = new_value
        self.assertEqual(extra, result['extra'])
示例#39
0
    def test_replace_multi(self):
        extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
        chassis = obj_utils.create_test_chassis(self.context, extra=extra,
                                                uuid=uuidutils.generate_uuid())
        new_value = 'new value'
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/extra/foo2',
                                     'value': new_value, 'op': 'replace'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(http_client.OK, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)

        extra["foo2"] = new_value
        self.assertEqual(extra, result['extra'])
示例#40
0
 def test_delete_chassis_with_node(self, mock_notify):
     chassis = obj_utils.create_test_chassis(self.context)
     obj_utils.create_test_node(self.context, chassis_id=chassis.id)
     response = self.delete('/chassis/%s' % chassis.uuid,
                            expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     self.assertIn(chassis.uuid, response.json['error_message'])
     mock_notify.assert_has_calls([mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.START),
                                   mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.ERROR,
                                   obj_fields.NotificationStatus.ERROR)])
示例#41
0
 def test_delete_chassis_with_node(self, mock_notify):
     chassis = obj_utils.create_test_chassis(self.context)
     obj_utils.create_test_node(self.context, chassis_id=chassis.id)
     response = self.delete('/chassis/%s' % chassis.uuid,
                            expect_errors=True)
     self.assertEqual(http_client.BAD_REQUEST, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     self.assertIn(chassis.uuid, response.json['error_message'])
     mock_notify.assert_has_calls([mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.INFO,
                                   obj_fields.NotificationStatus.START),
                                   mock.call(mock.ANY, mock.ANY, 'delete',
                                   obj_fields.NotificationLevel.ERROR,
                                   obj_fields.NotificationStatus.ERROR)])
示例#42
0
    def test_get_collection_pagination_no_uuid(self):
        fields = 'extra'
        limit = 2
        chassis_list = []
        for id_ in range(3):
            chassis = obj_utils.create_test_chassis(
                self.context, uuid=uuidutils.generate_uuid())
            chassis_list.append(chassis)

        data = self.get_json(
            '/chassis?fields=%s&limit=%s' % (fields, limit),
            headers={api_base.Version.string: str(api_v1.max_version())})

        self.assertEqual(limit, len(data['chassis']))
        self.assertIn('marker=%s' % chassis_list[limit - 1].uuid, data['next'])
示例#43
0
    def test_nodes_subresource(self):
        chassis = obj_utils.create_test_chassis(self.context)

        for id_ in range(2):
            obj_utils.create_test_node(self.context,
                                       chassis_id=chassis.id,
                                       uuid=uuidutils.generate_uuid())

        data = self.get_json('/chassis/%s/nodes' % chassis.uuid)
        self.assertEqual(2, len(data['nodes']))
        self.assertNotIn('next', data)

        # Test collection pagination
        data = self.get_json('/chassis/%s/nodes?limit=1' % chassis.uuid)
        self.assertEqual(1, len(data['nodes']))
        self.assertIn('next', data)
示例#44
0
    def test_nodes_subresource(self):
        chassis = obj_utils.create_test_chassis(self.context)

        for id_ in range(2):
            obj_utils.create_test_node(self.context,
                                       chassis_id=chassis.id,
                                       uuid=uuidutils.generate_uuid())

        data = self.get_json('/chassis/%s/nodes' % chassis.uuid)
        self.assertEqual(2, len(data['nodes']))
        self.assertNotIn('next', data)

        # Test collection pagination
        data = self.get_json('/chassis/%s/nodes?limit=1' % chassis.uuid)
        self.assertEqual(1, len(data['nodes']))
        self.assertIn('next', data)
示例#45
0
    def test_get_collection_pagination_no_uuid(self):
        fields = 'extra'
        limit = 2
        chassis_list = []
        for id_ in range(3):
            chassis = obj_utils.create_test_chassis(
                self.context,
                uuid=uuidutils.generate_uuid())
            chassis_list.append(chassis)

        data = self.get_json(
            '/chassis?fields=%s&limit=%s' % (fields, limit),
            headers={api_base.Version.string: str(api_v1.max_version())})

        self.assertEqual(limit, len(data['chassis']))
        self.assertIn('marker=%s' % chassis_list[limit - 1].uuid, data['next'])
示例#46
0
 def test_detail_against_single(self):
     chassis = obj_utils.create_test_chassis(self.context)
     response = self.get_json('/chassis/%s/detail' % chassis['uuid'],
                              expect_errors=True)
     self.assertEqual(http_client.NOT_FOUND, response.status_int)
示例#47
0
 def test_get_one(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis/%s' % chassis['uuid'])
     self.assertEqual(chassis.uuid, data['uuid'])
     self.assertIn('extra', data)
     self.assertIn('nodes', data)
示例#48
0
 def test_delete_nodes_subresource(self):
     chassis = obj_utils.create_test_chassis(self.context)
     response = self.delete('/chassis/%s/nodes' % chassis.uuid,
                            expect_errors=True)
     self.assertEqual(http_client.FORBIDDEN, response.status_int)
示例#49
0
 def test_one(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis')
     self.assertEqual(chassis.uuid, data['chassis'][0]["uuid"])
     self.assertNotIn('extra', data['chassis'][0])
     self.assertNotIn('nodes', data['chassis'][0])
示例#50
0
 def test_detail_against_single(self):
     chassis = obj_utils.create_test_chassis(self.context)
     response = self.get_json('/chassis/%s/detail' % chassis['uuid'],
                              expect_errors=True)
     self.assertEqual(http_client.NOT_FOUND, response.status_int)
示例#51
0
 def test_delete_nodes_subresource(self):
     chassis = obj_utils.create_test_chassis(self.context)
     response = self.delete('/chassis/%s/nodes' % chassis.uuid,
                            expect_errors=True)
     self.assertEqual(http_client.FORBIDDEN, response.status_int)
示例#52
0
 def test_one(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis')
     self.assertEqual(chassis.uuid, data['chassis'][0]["uuid"])
     self.assertNotIn('extra', data['chassis'][0])
     self.assertNotIn('nodes', data['chassis'][0])
示例#53
0
 def test_nodes_subresource_link(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis/%s' % chassis.uuid)
     self.assertIn('nodes', data)
示例#54
0
 def setUp(self):
     super(TestPatch, self).setUp()
     obj_utils.create_test_chassis(self.context)
示例#55
0
 def setUp(self):
     super(TestPatch, self).setUp()
     obj_utils.create_test_chassis(self.context)
示例#56
0
 def test_nodes_subresource_link(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis/%s' % chassis.uuid)
     self.assertIn('nodes', data)
示例#57
0
 def test_get_one(self):
     chassis = obj_utils.create_test_chassis(self.context)
     data = self.get_json('/chassis/%s' % chassis['uuid'])
     self.assertEqual(chassis.uuid, data['uuid'])
     self.assertIn('extra', data)
     self.assertIn('nodes', data)