Fix "AttributeError" when using "existing_users" context

Fixes bug https://bugs.launchpad.net/rally/+bug/1584765

Change-Id: I0f682de9c861933f3f35ea46c18256343c2bf441
This commit is contained in:
Antonio Messina 2016-05-23 17:19:02 +02:00
parent 341e996e35
commit b90555ef77
2 changed files with 9 additions and 1 deletions

View File

@ -67,7 +67,7 @@ class UserContextMixin(object):
# when it is supported there.
# Until it happens we use old "random" approach for
# 'existing_users' context.
self.user_choice_method = "random"
self._user_choice_method = "random"
return self._user_choice_method
def map_for_scenario(self, context_obj):

View File

@ -83,6 +83,14 @@ class UserContextMixinTestCase(test.TestCase):
self.mixin.map_for_scenario(context)
)
def test_user_choice_method_default(self):
self.mixin.context["config"]["users"]["user_choice_method"] = None
self.assertEqual(
"random",
self.mixin.user_choice_method
)
@mock.patch("%s.random.choice" % CTX,
side_effect=Exception("Should not be raised"))
def test_map_for_scenario_round_robin(self, mock_choice):