Merge "Remove use of is_temporary() in resource cleanup"
This commit is contained in:
commit
fe3d5b3f14
@ -719,8 +719,8 @@ class KeystoneMixin(SynchronizedDeletion):
|
||||
# TODO(boris-42): We should use such stuff in all list commands.
|
||||
resources = self._resource + "s"
|
||||
list_method = getattr(self._manager(), "list_%s" % resources)
|
||||
|
||||
return filter(kutils.is_temporary, list_method())
|
||||
return [r for r in list_method()
|
||||
if utils.name_matches_object(r.name, kutils.KeystoneScenario)]
|
||||
|
||||
|
||||
@base.resource("keystone", "user", order=next(_keystone_order),
|
||||
|
@ -15,15 +15,10 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from rally.common import utils
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task import atomic
|
||||
|
||||
|
||||
def is_temporary(resource):
|
||||
return utils.name_matches_object(resource.name, KeystoneScenario)
|
||||
|
||||
|
||||
class KeystoneScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Keystone scenarios with basic atomic actions."""
|
||||
|
||||
|
@ -20,6 +20,7 @@ from neutronclient.common import exceptions as neutron_exceptions
|
||||
|
||||
from rally.common import utils
|
||||
from rally.plugins.openstack.cleanup import resources
|
||||
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
||||
from tests.unit import test
|
||||
|
||||
BASE = "rally.plugins.openstack.cleanup.resources"
|
||||
@ -536,22 +537,25 @@ class KeystoneMixinTestCase(test.TestCase):
|
||||
mock_wrap().delete_some_resource.assert_called_once_with("id_a")
|
||||
|
||||
@mock.patch(
|
||||
"rally.plugins.openstack.scenarios.keystone.utils.is_temporary")
|
||||
"rally.common.utils.name_matches_object")
|
||||
@mock.patch("%s.keystone_wrapper.wrap" % BASE)
|
||||
def test_list(self, mock_wrap, mock_is_temporary):
|
||||
def test_list(self, mock_wrap, mock_name_matches_object):
|
||||
keystone_mixin = self.get_keystone_mixin()
|
||||
keystone_mixin._resource = "some_resource2"
|
||||
keystone_mixin._resource = "fake_resource"
|
||||
keystone_mixin.admin = mock.MagicMock()
|
||||
|
||||
result = [mock.MagicMock(), mock.MagicMock(), mock.MagicMock()]
|
||||
mock_is_temporary.side_effect = [True, True, False]
|
||||
result = [mock.MagicMock(name="rally_foo1"),
|
||||
mock.MagicMock(name="rally_foo2"),
|
||||
mock.MagicMock(name="foo3")]
|
||||
mock_name_matches_object.side_effect = [True, True, False]
|
||||
|
||||
mock_wrap().list_some_resource2s.return_value = result
|
||||
mock_wrap().list_fake_resources.return_value = result
|
||||
|
||||
self.assertSequenceEqual(result[:2], keystone_mixin.list())
|
||||
mock_wrap().list_some_resource2s.assert_called_once_with()
|
||||
mock_wrap().list_fake_resources.assert_called_once_with()
|
||||
|
||||
mock_is_temporary.assert_has_calls([mock.call(r) for r in result])
|
||||
mock_name_matches_object.assert_has_calls(
|
||||
[mock.call(r.name, kutils.KeystoneScenario) for r in result])
|
||||
|
||||
|
||||
class SwiftMixinTestCase(test.TestCase):
|
||||
|
@ -22,17 +22,6 @@ from tests.unit import test
|
||||
UTILS = "rally.plugins.openstack.scenarios.keystone.utils."
|
||||
|
||||
|
||||
class KeystoneUtilsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.common.utils.name_matches_object")
|
||||
def test_is_temporary(self, mock_name_matches_object):
|
||||
resource = mock.Mock()
|
||||
self.assertEqual(utils.is_temporary(resource),
|
||||
mock_name_matches_object.return_value)
|
||||
mock_name_matches_object.assert_called_once_with(
|
||||
resource.name, utils.KeystoneScenario)
|
||||
|
||||
|
||||
class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch("uuid.uuid4", return_value="pwd")
|
||||
|
Loading…
x
Reference in New Issue
Block a user