"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/tests/unit/objects/test_backup.py" between
cinder-15.0.1.tar.gz and cinder-15.1.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Train" series (latest release).

test_backup.py  (cinder-15.0.1):test_backup.py  (cinder-15.1.0)
skipping to change at line 144 skipping to change at line 144
def test_obj_field_restore_volume_id(self): def test_obj_field_restore_volume_id(self):
backup = objects.Backup(context=self.context, backup = objects.Backup(context=self.context,
restore_volume_id='2') restore_volume_id='2')
self.assertEqual('2', backup.restore_volume_id) self.assertEqual('2', backup.restore_volume_id)
def test_obj_field_metadata(self): def test_obj_field_metadata(self):
backup = objects.Backup(context=self.context, backup = objects.Backup(context=self.context,
metadata={'test_key': 'test_value'}) metadata={'test_key': 'test_value'})
self.assertEqual({'test_key': 'test_value'}, backup.metadata) self.assertEqual({'test_key': 'test_value'}, backup.metadata)
@mock.patch('cinder.objects.backup.Backup.get_by_id',
return_value=None)
def test_obj_field_parent(self, mock_lzy_ld):
backup = objects.Backup(context=self.context,
parent_id=None)
self.assertIsNone(backup.parent)
# Bug #1862635: should trigger a lazy load
backup = objects.Backup(context=self.context,
parent_id=fake.UUID5)
# need noqa here because of pyflakes issue #202
_ = backup.parent # noqa
mock_lzy_ld.assert_called_once()
def test_import_record(self): def test_import_record(self):
utils.replace_obj_loader(self, objects.Backup) utils.replace_obj_loader(self, objects.Backup)
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID, backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
parent_id=None, parent_id=None,
num_dependent_backups=0) num_dependent_backups=0)
export_string = backup.encode_record() export_string = backup.encode_record()
imported_backup = objects.Backup.decode_record(export_string) imported_backup = objects.Backup.decode_record(export_string)
# Make sure we don't lose data when converting from string # Make sure we don't lose data when converting from string
self.assertDictEqual(self._expected_backup(backup), imported_backup) self.assertDictEqual(self._expected_backup(backup), imported_backup)
@mock.patch('cinder.db.get_by_id', return_value=fake_backup)
def test_import_record_w_parent(self, backup_get):
full_backup = objects.Backup.get_by_id(self.context, fake.USER_ID)
self._compare(self, fake_backup, full_backup)
utils.replace_obj_loader(self, objects.Backup)
incr_backup = objects.Backup(context=self.context,
id=fake.BACKUP2_ID,
parent=full_backup,
parent_id=full_backup['id'],
num_dependent_backups=0)
export_string = incr_backup.encode_record()
imported_backup = objects.Backup.decode_record(export_string)
# Make sure we don't lose data when converting from string
self.assertDictEqual(self._expected_backup(incr_backup),
imported_backup)
def test_import_record_additional_info(self): def test_import_record_additional_info(self):
utils.replace_obj_loader(self, objects.Backup) utils.replace_obj_loader(self, objects.Backup)
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID, backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
parent_id=None, parent_id=None,
num_dependent_backups=0) num_dependent_backups=0)
extra_info = {'driver': {'key1': 'value1', 'key2': 'value2'}} extra_info = {'driver': {'key1': 'value1', 'key2': 'value2'}}
extra_info_copy = extra_info.copy() extra_info_copy = extra_info.copy()
export_string = backup.encode_record(extra_info=extra_info) export_string = backup.encode_record(extra_info=extra_info)
imported_backup = objects.Backup.decode_record(export_string) imported_backup = objects.Backup.decode_record(export_string)
skipping to change at line 176 skipping to change at line 208
self.assertDictEqual(extra_info_copy, extra_info) self.assertDictEqual(extra_info_copy, extra_info)
# Make sure we don't lose data when converting from string and that # Make sure we don't lose data when converting from string and that
# extra info is still there # extra info is still there
expected = self._expected_backup(backup) expected = self._expected_backup(backup)
expected['extra_info'] = extra_info expected['extra_info'] = extra_info
self.assertDictEqual(expected, imported_backup) self.assertDictEqual(expected, imported_backup)
def _expected_backup(self, backup): def _expected_backup(self, backup):
record = {name: field.to_primitive(backup, name, getattr(backup, name)) record = {name: field.to_primitive(backup, name, getattr(backup, name))
for name, field in backup.fields.items()} for name, field in backup.fields.items() if name != 'parent'}
return record return record
def test_import_record_additional_info_cant_overwrite(self): def test_import_record_additional_info_cant_overwrite(self):
utils.replace_obj_loader(self, objects.Backup) utils.replace_obj_loader(self, objects.Backup)
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID, backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
parent_id=None, parent_id=None,
num_dependent_backups=0) num_dependent_backups=0)
export_string = backup.encode_record(id='fake_id') export_string = backup.encode_record(id='fake_id')
imported_backup = objects.Backup.decode_record(export_string) imported_backup = objects.Backup.decode_record(export_string)
 End of changes. 3 change blocks. 
1 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)