Merge "[Core] Make iterations numeration starting from `1'"
This commit is contained in:
commit
2a08398705
@ -90,12 +90,15 @@ class UserContextMixin(object):
|
||||
else:
|
||||
# Second and last case - 'round_robin'.
|
||||
tenants_amount = len(context_obj["tenants"])
|
||||
tenant_id = sorted(context_obj["tenants"].keys())[
|
||||
context_obj["iteration"] % tenants_amount]
|
||||
# NOTE(amaretskiy): iteration is subtracted by `1' because it
|
||||
# starts from `1' but we count from `0'
|
||||
tenant_index = int((context_obj["iteration"] - 1) % tenants_amount)
|
||||
tenant_id = sorted(context_obj["tenants"].keys())[tenant_index]
|
||||
tenant = context_obj["tenants"][tenant_id]
|
||||
users = context_obj["tenants"][tenant_id]["users"]
|
||||
user = users[
|
||||
int(context_obj["iteration"] / tenants_amount) % len(users)]
|
||||
user_index = int(((context_obj["iteration"] - 1) / tenants_amount)
|
||||
% len(users))
|
||||
user = users[user_index]
|
||||
|
||||
scenario_ctx["user"], scenario_ctx["tenant"] = user, tenant
|
||||
|
||||
|
@ -120,7 +120,7 @@ class UserContextMixinTestCase(test.TestCase):
|
||||
}
|
||||
expected_ids = ["0_0", "1_0", "0_1", "1_1"] * 4
|
||||
mapped_ids = []
|
||||
for i in range(16):
|
||||
for i in range(1, 17):
|
||||
context["iteration"] = i
|
||||
user = self.mixin.map_for_scenario(context)
|
||||
mapped_ids.append(user["user"]["id"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user