Merge "Fix solidfire unit tests"

This commit is contained in:
Jenkins
2012-09-20 18:19:59 +00:00
committed by Gerrit Code Review

View File

@@ -84,6 +84,13 @@ class SolidFireVolumeTestCase(test.TestCase):
else: else:
LOG.error('Crap, unimplemented API call in Fake:%s' % method) LOG.error('Crap, unimplemented API call in Fake:%s' % method)
def fake_issue_api_request_no_volume(obj, method, params):
if method is 'ListVolumesForAccount':
LOG.info('Called Fake ListVolumesForAccount...')
return {'result': {'volumes': []}}
else:
return obj.fake_issue_api_request(method, params)
def fake_issue_api_request_fails(obj, method, params): def fake_issue_api_request_fails(obj, method, params):
return {'error': {'code': 000, return {'error': {'code': 000,
'name': 'DummyError', 'name': 'DummyError',
@@ -126,11 +133,8 @@ class SolidFireVolumeTestCase(test.TestCase):
'size': 1, 'size': 1,
'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
sfv = SolidFire() sfv = SolidFire()
try: self.assertRaises(exception.SolidFireAPIDataException,
sfv.create_volume(testvol) sfv.create_volume, testvol)
self.fail("Should have thrown Error")
except Exception:
pass
def test_create_sfaccount(self): def test_create_sfaccount(self):
sfv = SolidFire() sfv = SolidFire()
@@ -172,17 +176,14 @@ class SolidFireVolumeTestCase(test.TestCase):
def test_delete_volume_fails_no_volume(self): def test_delete_volume_fails_no_volume(self):
self.stubs.Set(SolidFire, '_issue_api_request', self.stubs.Set(SolidFire, '_issue_api_request',
self.fake_issue_api_request) self.fake_issue_api_request_no_volume)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'no-name', 'name': 'no-name',
'size': 1, 'size': 1,
'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
sfv = SolidFire() sfv = SolidFire()
try: self.assertRaises(exception.VolumeNotFound,
model_update = sfv.delete_volume(testvol) sfv.delete_volume, testvol)
self.fail("Should have thrown Error")
except Exception:
pass
def test_delete_volume_fails_account_lookup(self): def test_delete_volume_fails_account_lookup(self):
self.stubs.Set(SolidFire, '_issue_api_request', self.stubs.Set(SolidFire, '_issue_api_request',