예제 #1
0
 def test_save(self, mock_update_list):
     fake_call_args = {
         'node_id': self.bios_setting['node_id'],
         'name': self.bios_setting['name'],
         'value': self.bios_setting['value'],
         'version': self.bios_setting['version']
     }
     setting = [{
         'name': self.bios_setting['name'],
         'value': self.bios_setting['value'],
         'attribute_type': None,
         'allowable_values': None,
         'lower_bound': None,
         'max_length': None,
         'min_length': None,
         'read_only': None,
         'reset_required': None,
         'unique': None,
         'upper_bound': None
     }]
     bios_obj = objects.BIOSSetting(context=self.context, **fake_call_args)
     mock_update_list.return_value = [self.bios_setting]
     mock_update_list.call_args
     bios_obj.save()
     mock_update_list.assert_called_once_with(self.bios_setting['node_id'],
                                              setting,
                                              self.bios_setting['version'])
     self.assertEqual(self.bios_setting['node_id'], bios_obj.node_id)
     self.assertEqual(self.bios_setting['name'], bios_obj.name)
     self.assertEqual(self.bios_setting['value'], bios_obj.value)
예제 #2
0
def get_test_bios_setting(ctxt, **kw):
    """Return a BiosSettingList 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.
    """
    kw['object_type'] = 'bios'
    db_bios_setting = db_utils.get_test_bios_setting(**kw)
    bios_setting = objects.BIOSSetting(ctxt)
    for key in db_bios_setting:
        setattr(bios_setting, key, db_bios_setting[key])
    return bios_setting
예제 #3
0
    def test_create(self, mock_create_list):
        fake_call_args = {
            'node_id': self.bios_setting['node_id'],
            'name': self.bios_setting['name'],
            'value': self.bios_setting['value'],
            'attribute_type': self.bios_setting['attribute_type'],
            'allowable_values': self.bios_setting['allowable_values'],
            'read_only': self.bios_setting['read_only'],
            'reset_required': self.bios_setting['reset_required'],
            'unique': self.bios_setting['unique'],
            'version': self.bios_setting['version']
        }
        setting = [{
            'name': 'virtualization',
            'value': 'on',
            'attribute_type': 'Enumeration',
            'allowable_values': ['on', 'off'],
            'lower_bound': None,
            'max_length': None,
            'min_length': None,
            'read_only': False,
            'reset_required': True,
            'unique': False,
            'upper_bound': None
        }]

        bios_obj = objects.BIOSSetting(context=self.context, **fake_call_args)
        mock_create_list.return_value = [self.bios_setting]
        mock_create_list.call_args
        bios_obj.create()
        mock_create_list.assert_called_once_with(self.bios_setting['node_id'],
                                                 setting,
                                                 self.bios_setting['version'])
        self.assertEqual(self.bios_setting['node_id'], bios_obj.node_id)
        self.assertEqual(self.bios_setting['name'], bios_obj.name)
        self.assertEqual(self.bios_setting['value'], bios_obj.value)
        self.assertEqual(self.bios_setting['attribute_type'],
                         bios_obj.attribute_type)
        self.assertEqual(self.bios_setting['allowable_values'],
                         bios_obj.allowable_values)
        self.assertEqual(self.bios_setting['read_only'], bios_obj.read_only)
        self.assertEqual(self.bios_setting['reset_required'],
                         bios_obj.reset_required)
        self.assertEqual(self.bios_setting['unique'], bios_obj.unique)
예제 #4
0
 def test_save(self, mock_update_list):
     fake_call_args = {
         'node_id': self.bios_setting['node_id'],
         'name': self.bios_setting['name'],
         'value': self.bios_setting['value'],
         'version': self.bios_setting['version']
     }
     setting = [{
         'name': self.bios_setting['name'],
         'value': self.bios_setting['value']
     }]
     bios_obj = objects.BIOSSetting(context=self.context, **fake_call_args)
     mock_update_list.return_value = [self.bios_setting]
     mock_update_list.call_args
     bios_obj.save()
     mock_update_list.assert_called_once_with(self.bios_setting['node_id'],
                                              setting,
                                              self.bios_setting['version'])
     self.assertEqual(self.bios_setting['node_id'], bios_obj.node_id)
     self.assertEqual(self.bios_setting['name'], bios_obj.name)
     self.assertEqual(self.bios_setting['value'], bios_obj.value)