def test_usage_from_backup(self): raw_backup = { 'project_id': fake.PROJECT_ID, 'user_id': fake.USER_ID, 'availability_zone': 'nova', 'id': fake.BACKUP_ID, 'host': 'fake_host', 'display_name': 'test_backup', 'created_at': datetime.datetime(2015, 1, 1, 1, 1, 1), 'status': 'available', 'volume_id': fake.VOLUME_ID, 'size': 1, 'service_metadata': None, 'service': 'cinder.backup.drivers.swift', 'fail_reason': None, 'parent_id': fake.BACKUP2_ID, 'num_dependent_backups': 0, 'snapshot_id': None, } ctxt = context.get_admin_context() backup_obj = fake_backup.fake_backup_obj(ctxt, **raw_backup) # Make it easier to find out differences between raw and expected. expected_backup = raw_backup.copy() expected_backup['tenant_id'] = expected_backup.pop('project_id') expected_backup['backup_id'] = expected_backup.pop('id') expected_backup['created_at'] = ( six.text_type(expected_backup['created_at']) + '+00:00') usage_info = volume_utils._usage_from_backup(backup_obj) self.assertDictMatch(expected_backup, usage_info)
def test_usage_from_backup(self): raw_backup = { 'project_id': '12b0330ec2584a', 'user_id': '158cba1b8c2bb6008e', 'availability_zone': 'nova', 'id': 'fake_id', 'host': 'fake_host', 'display_name': 'test_backup', 'created_at': '2014-12-11T10:10:00', 'status': 'available', 'volume_id': 'fake_volume_id', 'size': 1, 'service_metadata': None, 'service': 'cinder.backup.drivers.swift', 'fail_reason': None, 'parent_id': 'fake_parent_id', 'num_dependent_backups': 0, } # Make it easier to find out differences between raw and expected. expected_backup = raw_backup.copy() expected_backup['tenant_id'] = expected_backup.pop('project_id') expected_backup['backup_id'] = expected_backup.pop('id') usage_info = volume_utils._usage_from_backup(raw_backup) self.assertEqual(expected_backup, usage_info)
def test_usage_from_backup(self): raw_backup = { "project_id": "12b0330ec2584a", "user_id": "158cba1b8c2bb6008e", "availability_zone": "nova", "id": "fake_id", "host": "fake_host", "display_name": "test_backup", "created_at": "2014-12-11T10:10:00", "status": "available", "volume_id": "fake_volume_id", "size": 1, "service_metadata": None, "service": "cinder.backup.drivers.swift", "fail_reason": None, "parent_id": "fake_parent_id", "num_dependent_backups": 0, } # Make it easier to find out differences between raw and expected. expected_backup = raw_backup.copy() expected_backup["tenant_id"] = expected_backup.pop("project_id") expected_backup["backup_id"] = expected_backup.pop("id") usage_info = volume_utils._usage_from_backup(raw_backup) self.assertEqual(expected_backup, usage_info)
def test_usage_from_backup(self): raw_backup = { "project_id": fake.PROJECT_ID, "user_id": fake.USER_ID, "availability_zone": "nova", "id": fake.BACKUP_ID, "host": "fake_host", "display_name": "test_backup", "created_at": datetime.datetime(2015, 1, 1, 1, 1, 1), "status": "available", "volume_id": fake.VOLUME_ID, "size": 1, "service_metadata": None, "service": "cinder.backup.drivers.swift", "fail_reason": None, "parent_id": fake.BACKUP2_ID, "num_dependent_backups": 0, "snapshot_id": None, } ctxt = context.get_admin_context() backup_obj = fake_backup.fake_backup_obj(ctxt, **raw_backup) # Make it easier to find out differences between raw and expected. expected_backup = raw_backup.copy() expected_backup["tenant_id"] = expected_backup.pop("project_id") expected_backup["backup_id"] = expected_backup.pop("id") expected_backup["created_at"] = six.text_type(expected_backup["created_at"]) + "+00:00" usage_info = volume_utils._usage_from_backup(backup_obj) self.assertDictEqual(expected_backup, usage_info)