Пример #1
0
def post_get_test_node(**kw):
    # NOTE(lucasagomes): When creating a node via API (POST)
    #                    we have to use chassis_uuid
    node = node_post_data(**kw)
    chassis = utils.get_test_chassis()
    node['chassis_uuid'] = kw.get('chassis_uuid', chassis['uuid'])
    return node
Пример #2
0
def post_get_test_node(**kw):
    # NOTE(lucasagomes): When creating a node via API (POST)
    #                    we have to use chassis_uuid
    node = node_post_data(**kw)
    chassis = utils.get_test_chassis()
    node['chassis_uuid'] = kw.get('chassis_uuid', chassis['uuid'])
    return node
Пример #3
0
    def test_create(self):
        chassis = objects.Chassis(self.context, **self.fake_chassis)
        with mock.patch.object(self.dbapi, 'create_chassis',
                               autospec=True) as mock_create_chassis:
            mock_create_chassis.return_value = db_utils.get_test_chassis()

            chassis.create()

            args, _kwargs = mock_create_chassis.call_args
            self.assertEqual(objects.Chassis.VERSION, args[0]['version'])
Пример #4
0
    def test_create(self):
        chassis = objects.Chassis(self.context, **self.fake_chassis)
        with mock.patch.object(self.dbapi, 'create_chassis',
                               autospec=True) as mock_create_chassis:
            mock_create_chassis.return_value = db_utils.get_test_chassis()

            chassis.create()

            args, _kwargs = mock_create_chassis.call_args
            self.assertEqual(objects.Chassis.VERSION, args[0]['version'])
Пример #5
0
def get_test_chassis(ctxt, **kw):
    """Return a Chassis object with appropriate attributes.

    NOTE: The object leaves the attributes marked as changed, such
    that a create() could be used to commit it to the DB.
    """
    db_chassis = db_utils.get_test_chassis(**kw)
    # Let DB generate ID if it isn't specified explicitly
    if 'id' not in kw:
        del db_chassis['id']
    chassis = objects.Chassis(ctxt)
    for key in db_chassis:
        setattr(chassis, key, db_chassis[key])
    return chassis
Пример #6
0
    def test_save(self):
        uuid = self.fake_chassis['uuid']
        extra = {"test": 123}
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        with mock.patch.object(self.dbapi, 'get_chassis_by_uuid',
                               autospec=True) as mock_get_chassis:
            mock_get_chassis.return_value = self.fake_chassis
            with mock.patch.object(self.dbapi, 'update_chassis',
                                   autospec=True) as mock_update_chassis:
                mock_update_chassis.return_value = (
                    utils.get_test_chassis(extra=extra, updated_at=test_time))
                c = objects.Chassis.get_by_uuid(self.context, uuid)
                c.extra = extra
                c.save()

                mock_get_chassis.assert_called_once_with(uuid)
                mock_update_chassis.assert_called_once_with(
                    uuid, {'extra': {"test": 123}})
                self.assertEqual(self.context, c._context)
                res_updated_at = (c.updated_at).replace(tzinfo=None)
                self.assertEqual(test_time, res_updated_at)
Пример #7
0
    def test_save(self):
        uuid = self.fake_chassis['uuid']
        extra = {"test": 123}
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        with mock.patch.object(self.dbapi, 'get_chassis_by_uuid',
                               autospec=True) as mock_get_chassis:
            mock_get_chassis.return_value = self.fake_chassis
            with mock.patch.object(self.dbapi, 'update_chassis',
                                   autospec=True) as mock_update_chassis:
                mock_update_chassis.return_value = (
                    utils.get_test_chassis(extra=extra, updated_at=test_time))
                c = objects.Chassis.get_by_uuid(self.context, uuid)
                c.extra = extra
                c.save()

                mock_get_chassis.assert_called_once_with(uuid)
                mock_update_chassis.assert_called_once_with(
                    uuid, {'extra': {"test": 123}})
                self.assertEqual(self.context, c._context)
                res_updated_at = (c.updated_at).replace(tzinfo=None)
                self.assertEqual(test_time, res_updated_at)
Пример #8
0
def chassis_post_data(**kw):
    chassis = utils.get_test_chassis(**kw)
    internal = chassis_controller.ChassisPatchType.internal_attrs()
    return remove_internal(chassis, internal)
Пример #9
0
def chassis_post_data(**kw):
    chassis = db_utils.get_test_chassis(**kw)
    # version is not part of the API object
    chassis.pop('version')
    internal = chassis_controller.ChassisPatchType.internal_attrs()
    return remove_internal(chassis, internal)
Пример #10
0
def chassis_post_data(**kw):
    chassis = db_utils.get_test_chassis(**kw)
    return remove_other_fields(chassis,
                               chassis_controller.CHASSIS_SCHEMA['properties'])
Пример #11
0
def chassis_post_data(**kw):
    chassis = utils.get_test_chassis(**kw)
    internal = chassis_controller.ChassisPatchType.internal_attrs()
    return remove_internal(chassis, internal)
Пример #12
0
def chassis_post_data(**kw):
    chassis = db_utils.get_test_chassis(**kw)
    # version is not part of the API object
    chassis.pop('version')
    internal = chassis_controller.ChassisPatchType.internal_attrs()
    return remove_internal(chassis, internal)
Пример #13
0
 def setUp(self):
     super(TestChassisObject, self).setUp()
     self.fake_chassis = utils.get_test_chassis()
Пример #14
0
 def setUp(self):
     super(TestChassisObject, self).setUp()
     self.fake_chassis = utils.get_test_chassis()