Add coverage for StoreLocation
This patch adds code coverage (UTs) for methods in StoreLocation class: 1) process_specs 2) get_uri 3) parse_uri It also adds a missing method (_set_url_prefix) coverage in Multistore cinder tests (test_multistore_cinder). Change-Id: I8ced5af11669fb131c665ce53be57143f2c7b518
This commit is contained in:
parent
c0c4969a4a
commit
3666d2d2e4
|
@ -513,3 +513,16 @@ class TestCinderStoreBase(object):
|
|||
exceptions.BackendException,
|
||||
cinder.Store._wait_resize_device,
|
||||
fake_vol, fake_file)
|
||||
|
||||
def test_process_specs(self):
|
||||
self.location.process_specs()
|
||||
self.assertEqual('cinder', self.location.scheme)
|
||||
self.assertEqual(self.volume_id, self.location.volume_id)
|
||||
|
||||
def _test_get_uri(self, expected_uri):
|
||||
uri = self.location.get_uri()
|
||||
self.assertEqual(expected_uri, uri)
|
||||
|
||||
def _test_parse_uri_invalid(self, uri):
|
||||
self.assertRaises(
|
||||
exceptions.BadStoreUri, self.location.parse_uri, uri)
|
||||
|
|
|
@ -55,6 +55,10 @@ class TestCinderStore(base.StoreBaseTest,
|
|||
self.hash_algo = 'sha256'
|
||||
cinder._reset_cinder_session()
|
||||
self.config(cinder_mount_point_base=None)
|
||||
self.volume_id = str(uuid.uuid4())
|
||||
specs = {'scheme': 'cinder',
|
||||
'volume_id': self.volume_id}
|
||||
self.location = cinder.StoreLocation(specs, self.conf)
|
||||
|
||||
def test_get_cinderclient_with_user_overriden(self):
|
||||
self._test_get_cinderclient_with_user_overriden()
|
||||
|
@ -168,3 +172,15 @@ class TestCinderStore(base.StoreBaseTest,
|
|||
# warning
|
||||
self.config(cinder_volume_type='some_random_type')
|
||||
self._test_configure_add_invalid_type()
|
||||
|
||||
def test_get_uri(self):
|
||||
expected_uri = 'cinder://%s' % self.volume_id
|
||||
self._test_get_uri(expected_uri)
|
||||
|
||||
def test_parse_uri_valid(self):
|
||||
expected_uri = 'cinder://%s' % self.volume_id
|
||||
self.location.parse_uri(expected_uri)
|
||||
|
||||
def test_parse_uri_invalid(self):
|
||||
uri = 'cinder://%s' % 'fake_volume'
|
||||
self._test_parse_uri_invalid(uri)
|
||||
|
|
|
@ -89,6 +89,11 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
|
|||
project_id='admin_project')
|
||||
cinder._reset_cinder_session()
|
||||
self.config(cinder_mount_point_base=None, group='cinder1')
|
||||
self.volume_id = str(uuid.uuid4())
|
||||
specs = {'scheme': 'cinder',
|
||||
'volume_id': self.volume_id}
|
||||
self.location = cinder.StoreLocation(specs, self.conf,
|
||||
backend_group='cinder1')
|
||||
|
||||
def test_location_url_prefix_is_set(self):
|
||||
self.assertEqual("cinder://cinder1", self.store.url_prefix)
|
||||
|
@ -293,3 +298,18 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
|
|||
conf=self.conf)
|
||||
self.store.delete(loc, context=self.context)
|
||||
fake_volumes.delete.assert_called_once_with(fake_volume_uuid)
|
||||
|
||||
def test_set_url_prefix(self):
|
||||
self.assertEqual('cinder://cinder1', self.store._url_prefix)
|
||||
|
||||
def test_get_uri(self):
|
||||
expected_uri = 'cinder://cinder1/%s' % self.volume_id
|
||||
self._test_get_uri(expected_uri)
|
||||
|
||||
def test_parse_uri_valid(self):
|
||||
expected_uri = 'cinder://cinder1/%s' % self.volume_id
|
||||
self.location.parse_uri(expected_uri)
|
||||
|
||||
def test_parse_uri_invalid(self):
|
||||
uri = 'cinder://cinder1/%s' % 'fake_volume'
|
||||
self._test_parse_uri_invalid(uri)
|
||||
|
|
Loading…
Reference in New Issue