Unskip tests caused by bug 1599333

There is now a second .get() call in osc_lib.utils.find_resources.
These tests were failing because they only mocked a single access
call to .get(). Ensure there are two calls to .get(), with the
first one raising an exception.

Change-Id: Idd2ad4a27a6db5bee633cc37a1042dbb0a57aa71
Closes-Bug: #1599333
This commit is contained in:
Steve Martinelli 2016-07-07 22:41:07 -04:00
parent ffb232a90e
commit 9f09d8c5d4
4 changed files with 24 additions and 18 deletions

View File

@ -15,7 +15,6 @@
import copy import copy
import mock import mock
import testtools
from openstackclient.identity.v3 import identity_provider from openstackclient.identity.v3 import identity_provider
from openstackclient.tests import fakes from openstackclient.tests import fakes
@ -600,11 +599,14 @@ class TestIdentityProviderShow(TestIdentityProvider):
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER), copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
loaded=True, loaded=True,
) )
self.identity_providers_mock.get.side_effect = [Exception("Not found"),
ret]
self.identity_providers_mock.get.return_value = ret self.identity_providers_mock.get.return_value = ret
# Get the command object to test # Get the command object to test
self.cmd = identity_provider.ShowIdentityProvider(self.app, None) self.cmd = identity_provider.ShowIdentityProvider(self.app, None)
@testtools.skip("skip until bug 1599333 is fixed")
def test_identity_provider_show(self): def test_identity_provider_show(self):
arglist = [ arglist = [
identity_fakes.idp_id, identity_fakes.idp_id,

View File

@ -16,7 +16,6 @@
import mock import mock
from osc_lib import exceptions from osc_lib import exceptions
import testtools
from openstackclient.identity.v3 import project from openstackclient.identity.v3 import project
from openstackclient.tests.identity.v3 import fakes as identity_fakes from openstackclient.tests.identity.v3 import fakes as identity_fakes
@ -731,14 +730,16 @@ class TestProjectShow(TestProject):
self.project = identity_fakes.FakeProject.create_one_project( self.project = identity_fakes.FakeProject.create_one_project(
attrs={'domain_id': self.domain.id}) attrs={'domain_id': self.domain.id})
self.projects_mock.get.return_value = self.project
# Get the command object to test # Get the command object to test
self.cmd = project.ShowProject(self.app, None) self.cmd = project.ShowProject(self.app, None)
@testtools.skip("skip until bug 1599333 is fixed")
def test_project_show(self): def test_project_show(self):
self.projects_mock.get.side_effect = [Exception("Not found"),
self.project]
self.projects_mock.get.return_value = self.project
arglist = [ arglist = [
self.project.id, self.project.id,
] ]
@ -761,6 +762,7 @@ class TestProjectShow(TestProject):
# returns a two-part tuple with a tuple of column names and a tuple of # returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown. # data to be shown.
columns, data = self.cmd.take_action(parsed_args) columns, data = self.cmd.take_action(parsed_args)
self.projects_mock.get.assert_called_with( self.projects_mock.get.assert_called_with(
self.project.id, self.project.id,
parents_as_list=False, parents_as_list=False,
@ -788,7 +790,6 @@ class TestProjectShow(TestProject):
) )
self.assertEqual(datalist, data) self.assertEqual(datalist, data)
@testtools.skip("skip until bug 1599333 is fixed")
def test_project_show_parents(self): def test_project_show_parents(self):
self.project = identity_fakes.FakeProject.create_one_project( self.project = identity_fakes.FakeProject.create_one_project(
attrs={ attrs={
@ -796,6 +797,8 @@ class TestProjectShow(TestProject):
'parents': [{'project': {'id': self.project.parent_id}}] 'parents': [{'project': {'id': self.project.parent_id}}]
} }
) )
self.projects_mock.get.side_effect = [Exception("Not found"),
self.project]
self.projects_mock.get.return_value = self.project self.projects_mock.get.return_value = self.project
arglist = [ arglist = [
@ -848,7 +851,6 @@ class TestProjectShow(TestProject):
) )
self.assertEqual(data, datalist) self.assertEqual(data, datalist)
@testtools.skip("skip until bug 1599333 is fixed")
def test_project_show_subtree(self): def test_project_show_subtree(self):
self.project = identity_fakes.FakeProject.create_one_project( self.project = identity_fakes.FakeProject.create_one_project(
attrs={ attrs={
@ -856,6 +858,8 @@ class TestProjectShow(TestProject):
'subtree': [{'project': {'id': 'children-id'}}] 'subtree': [{'project': {'id': 'children-id'}}]
} }
) )
self.projects_mock.get.side_effect = [Exception("Not found"),
self.project]
self.projects_mock.get.return_value = self.project self.projects_mock.get.return_value = self.project
arglist = [ arglist = [
@ -908,7 +912,6 @@ class TestProjectShow(TestProject):
) )
self.assertEqual(data, datalist) self.assertEqual(data, datalist)
@testtools.skip("skip until bug 1599333 is fixed")
def test_project_show_parents_and_children(self): def test_project_show_parents_and_children(self):
self.project = identity_fakes.FakeProject.create_one_project( self.project = identity_fakes.FakeProject.create_one_project(
attrs={ attrs={
@ -917,6 +920,8 @@ class TestProjectShow(TestProject):
'subtree': [{'project': {'id': 'children-id'}}] 'subtree': [{'project': {'id': 'children-id'}}]
} }
) )
self.projects_mock.get.side_effect = [Exception("Not found"),
self.project]
self.projects_mock.get.return_value = self.project self.projects_mock.get.return_value = self.project
arglist = [ arglist = [

View File

@ -14,8 +14,6 @@
import copy import copy
import testtools
from openstackclient.identity.v3 import service_provider from openstackclient.identity.v3 import service_provider
from openstackclient.tests import fakes from openstackclient.tests import fakes
from openstackclient.tests.identity.v3 import fakes as service_fakes from openstackclient.tests.identity.v3 import fakes as service_fakes
@ -393,11 +391,13 @@ class TestServiceProviderShow(TestServiceProvider):
copy.deepcopy(service_fakes.SERVICE_PROVIDER), copy.deepcopy(service_fakes.SERVICE_PROVIDER),
loaded=True, loaded=True,
) )
self.service_providers_mock.get.side_effect = [Exception("Not found"),
ret]
self.service_providers_mock.get.return_value = ret self.service_providers_mock.get.return_value = ret
# Get the command object to test # Get the command object to test
self.cmd = service_provider.ShowServiceProvider(self.app, None) self.cmd = service_provider.ShowServiceProvider(self.app, None)
@testtools.skip("skip until bug 1599333 is fixed")
def test_service_provider_show(self): def test_service_provider_show(self):
arglist = [ arglist = [
service_fakes.sp_id, service_fakes.sp_id,

View File

@ -19,7 +19,6 @@ from cinderclient.v1 import volume_snapshots
from cinderclient.v1 import volumes from cinderclient.v1 import volumes
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
import testtools
from openstackclient.tests import utils as test_utils from openstackclient.tests import utils as test_utils
from openstackclient.volume import client # noqa from openstackclient.volume import client # noqa
@ -45,16 +44,16 @@ class TestFindResourceVolumes(test_utils.TestCase):
api.client.get = mock.Mock() api.client.get = mock.Mock()
resp = mock.Mock() resp = mock.Mock()
body = {"volumes": [{"id": ID, 'display_name': NAME}]} body = {"volumes": [{"id": ID, 'display_name': NAME}]}
api.client.get.side_effect = [Exception("Not found"), (resp, body)] api.client.get.side_effect = [Exception("Not found"),
Exception("Not found"),
(resp, body)]
self.manager = volumes.VolumeManager(api) self.manager = volumes.VolumeManager(api)
@testtools.skip("skip until bug 1599333 is fixed")
def test_find(self): def test_find(self):
result = utils.find_resource(self.manager, NAME) result = utils.find_resource(self.manager, NAME)
self.assertEqual(ID, result.id) self.assertEqual(ID, result.id)
self.assertEqual(NAME, result.display_name) self.assertEqual(NAME, result.display_name)
@testtools.skip("skip until bug 1599333 is fixed")
def test_not_find(self): def test_not_find(self):
self.assertRaises(exceptions.CommandError, utils.find_resource, self.assertRaises(exceptions.CommandError, utils.find_resource,
self.manager, 'GeorgeMartin') self.manager, 'GeorgeMartin')
@ -69,16 +68,16 @@ class TestFindResourceVolumeSnapshots(test_utils.TestCase):
api.client.get = mock.Mock() api.client.get = mock.Mock()
resp = mock.Mock() resp = mock.Mock()
body = {"snapshots": [{"id": ID, 'display_name': NAME}]} body = {"snapshots": [{"id": ID, 'display_name': NAME}]}
api.client.get.side_effect = [Exception("Not found"), (resp, body)] api.client.get.side_effect = [Exception("Not found"),
Exception("Not found"),
(resp, body)]
self.manager = volume_snapshots.SnapshotManager(api) self.manager = volume_snapshots.SnapshotManager(api)
@testtools.skip("skip until bug 1599333 is fixed")
def test_find(self): def test_find(self):
result = utils.find_resource(self.manager, NAME) result = utils.find_resource(self.manager, NAME)
self.assertEqual(ID, result.id) self.assertEqual(ID, result.id)
self.assertEqual(NAME, result.display_name) self.assertEqual(NAME, result.display_name)
@testtools.skip("skip until bug 1599333 is fixed")
def test_not_find(self): def test_not_find(self):
self.assertRaises(exceptions.CommandError, utils.find_resource, self.assertRaises(exceptions.CommandError, utils.find_resource,
self.manager, 'GeorgeMartin') self.manager, 'GeorgeMartin')