def create_random_forum_message(): theme = random.choice(FORUM_THEMES) subject = id_generator(random.randint(1, 20)) message = id_generator(random.randint(20, 200)) return create_forum_body(theme=theme, subject=subject, message=message)
def create_random_user(): name = id_generator(6) username = id_generator(6) pwd = id_generator(6) role = random.choice(USER_ROLES) email = '{}@{}'.format(id_generator(6), id_generator(6)) return create_user_body(name, username, pwd, role, email)
def given_a_group1_of_servers_in_a_tenant(step, number_servers): world.number_servers = int(number_servers) world.servers_body = [] for x in range(world.number_servers): world.rules = [] server_id = Utils.id_generator(size=6) number_rules = random.randint(1, 5) for rule in range(number_rules): rule_body = Rule_Utils.create_scale_specific_rule() req = api_utils.create_rule(world.tenant_id, server_id, body=rule_body) assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content)) rule_id = req.json()[RULE_ID] world.rules.append( Rule_Utils.create_rule_body(action=None, rule_id=rule_id, condition=None, name=rule_body['name'])) server_dict = {SERVER_ID: server_id, RULES: world.rules} world.servers_body.append(server_dict)
def retrieve_non_existent_subscription(step, server_id): world.server_id = server_id world.req = api_utils.retrieve_subscription( tenant_id=world.tenant_id, server_id=world.server_id, subscription_id=Utils.id_generator(10), headers=world.headers)
def retrieve_non_existent_subscription(context, server_id): context.server_id = server_id context.req = api_utils.retrieve_subscription( tenant_id=context.tenant_id, server_id=context.server_id, subscription_id=Utils.id_generator(10), headers=context.headers)
def retrieve_non_existent_subscription(step, server_id): world.server_id = server_id world.req = api_utils.retrieve_subscription( tenant_id=world.tenant_id, server_id=world.server_id, subscription_id=Utils.id_generator(10), headers=world.headers, )
def retrieve_subscription(context, server_id): if server_id == RANDOM: context.server_id = Utils.id_generator(10) else: context.server_id = server_id context.req = api_utils.retrieve_subscription(tenant_id=context.tenant_id, server_id=context.server_id, subscription_id=context.subscription_id, headers=context.headers)
def when_i_create_a_scale_rule_with_group1_and_group2(step, rule_name, action): if rule_name == 'random': rule_name = Utils.id_generator() action = Rule_Utils.create_rule_action_dict(action_name='notify-scale', operation=action) world.req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, rule_name=rule_name, cpu=world.cpu, mem=world.mem, action=action, headers=world.headers)
def when_i_create_a_scale_rule_with_group1_and_group2(context, rule_name, action): if rule_name == 'random': rule_name = Utils.id_generator() action = Rule_Utils.create_rule_action_dict(action_name='notify-scale', operation=action) context.req = api_utils.create_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_name=rule_name, cpu=context.cpu, mem=context.mem, hdd=context.hdd, net=context.net, action=action, headers=context.headers)
def new_subscription_in_server(context, server_id, url_to_notify): context.url_to_notify = url_to_notify if server_id == RANDOM: context.server_id = Utils.id_generator(10) else: context.server_id = server_id context.req = api_utils.create_subscription(tenant_id=context.tenant_id, server_id=context.server_id, rule_id=context.rule_id, url=context.url_to_notify, headers=context.headers)
def retrieve_subscription(step, server_id): if server_id == RANDOM: world.server_id = Utils.id_generator(10) else: world.server_id = server_id world.req = api_utils.retrieve_subscription( tenant_id=world.tenant_id, server_id=world.server_id, subscription_id=world.subscription_id, headers=world.headers)
def retrieve_subscription(context, server_id): if server_id == RANDOM: context.server_id = Utils.id_generator(10) else: context.server_id = server_id context.req = api_utils.retrieve_subscription( tenant_id=context.tenant_id, server_id=context.server_id, subscription_id=context.subscription_id, headers=context.headers)
def when_i_update_the_notify_rule_with_group1_group2_and_group3(step, new_name, new_body, new_mail, server_id): if new_name == RANDOM: world.rule_name = Utils.id_generator() else: world.rule_name = new_name world.server_id = server_id world.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-email', body=new_body, email=new_mail) world.req = api_utils.update_rule(tenant_id=world.tenant_id, server_id=world.server_id, rule_name=world.rule_name, cpu=world.cpu, mem=world.mem, hdd=world.hdd, net=world.net, action=world.rule_action, headers=world.headers, rule_id=world.rule_id)
def when_i_update_the_notify_rule_with_group1_group2_and_group3(step, new_name, new_body, new_mail, server_id): if new_name == RANDOM: world.rule_name = Utils.id_generator() else: world.rule_name = new_name world.server_id = server_id world.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-email', body=new_body, email=new_mail) world.req = api_utils.update_rule(tenant_id=world.tenant_id, server_id=world.server_id, rule_name=world.rule_name, cpu=world.cpu, mem=world.mem, action=world.rule_action, headers=world.headers, rule_id=world.rule_id)
def retrieve_subscription(step, server_id): if server_id == RANDOM: world.server_id = Utils.id_generator(10) else: world.server_id = server_id world.req = api_utils.retrieve_subscription( tenant_id=world.tenant_id, server_id=world.server_id, subscription_id=world.subscription_id, headers=world.headers, )
def new_subscription_in_server(step, server_id, url_to_notify): world.url_to_notify = url_to_notify if server_id == RANDOM: world.server_id = Utils.id_generator(10) else: world.server_id = server_id world.req = api_utils.create_subscription(tenant_id=world.tenant_id, server_id=world.server_id, rule_id=world.rule_id, url=world.url_to_notify, headers=world.headers)
def when_i_update_the_notify_rule_with_group1_group2_and_group3(context, new_name, new_body, new_mail, server_id): if new_name == RANDOM: context.rule_name = Utils.id_generator() else: context.rule_name = new_name context.server_id = server_id context.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-email', body=new_body, email=new_mail) context.req = api_utils.update_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_name=context.rule_name, cpu=context.cpu, mem=context.mem, hdd=context.hdd, net=context.net, action=context.rule_action, headers=context.headers, rule_id=context.rule_id)
def when_i_update_the_rule_with_group1_and_group2(step, new_name, new_action, server_id): if new_name == 'random': world.rule_name = Utils.id_generator() else: world.rule_name = new_name world.server_id = server_id world.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-scale', operation=new_action) world.req = api_utils.update_rule(tenant_id=world.tenant_id, server_id=world.server_id, rule_name=world.rule_name, cpu=world.cpu, mem=world.mem, hdd=world.hdd, net=world.net, action=world.rule_action, headers=world.headers, rule_id=world.rule_id)
def when_i_update_the_rule_with_group1_and_group2(step, new_name, new_action, server_id): if new_name == 'random': world.rule_name = Utils.id_generator() else: world.rule_name = new_name world.server_id = server_id world.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-scale', operation=new_action) world.req = api_utils.update_rule(tenant_id=world.tenant_id, server_id=world.server_id, rule_name=world.rule_name, cpu=world.cpu, mem=world.mem, action=world.rule_action, headers=world.headers, rule_id=world.rule_id)
def new_subscription_in_server(step, server_id, url_to_notify): world.url_to_notify = url_to_notify if server_id == RANDOM: world.server_id = Utils.id_generator(10) else: world.server_id = server_id world.req = api_utils.create_subscription( tenant_id=world.tenant_id, server_id=world.server_id, rule_id=world.rule_id, url=world.url_to_notify, headers=world.headers, )
def when_i_update_the_rule_with_group1_and_group2(context, new_name, new_action, server_id): if new_name == 'random': context.rule_name = Utils.id_generator() else: context.rule_name = new_name context.server_id = server_id context.rule_action = Rule_Utils.create_rule_action_dict(action_name='notify-scale', operation=new_action) context.req = api_utils.update_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_name=context.rule_name, cpu=context.cpu, mem=context.mem, hdd=context.hdd, net=context.net, action=context.rule_action, headers=context.headers, rule_id=context.rule_id)
def given_a_group1_of_servers_in_a_tenant(step, number_servers): world.number_servers = int(number_servers) world.servers_body = [] for x in range(world.number_servers): world.rules = [] server_id = Utils.id_generator(size=6) number_rules = random.randint(1, 5) for rule in range(number_rules): rule_body = Rule_Utils.create_scale_specific_rule() req = api_utils.create_rule(world.tenant_id, server_id, body=rule_body) assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content)) rule_id = req.json()[RULE_ID] world.rules.append(Rule_Utils.create_rule_body(action=None, rule_id=rule_id, condition=None, name=rule_body['name'])) server_dict = {SERVER_ID: server_id, RULES: world.rules} world.servers_body.append(server_dict)
def when_i_update_the_notify_rule_with_group1_group2_and_group3( context, new_name, new_body, new_mail, server_id): if new_name == RANDOM: context.rule_name = Utils.id_generator() else: context.rule_name = new_name context.server_id = server_id context.rule_action = Rule_Utils.create_rule_action_dict( action_name='notify-email', body=new_body, email=new_mail) context.req = api_utils.update_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_name=context.rule_name, cpu=context.cpu, mem=context.mem, hdd=context.hdd, net=context.net, action=context.rule_action, headers=context.headers, rule_id=context.rule_id)
def when_i_update_the_rule_with_group1_and_group2(context, new_name, new_action, server_id): if new_name == 'random': context.rule_name = Utils.id_generator() else: context.rule_name = new_name context.server_id = server_id context.rule_action = Rule_Utils.create_rule_action_dict( action_name='notify-scale', operation=new_action) context.req = api_utils.update_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_name=context.rule_name, cpu=context.cpu, mem=context.mem, hdd=context.hdd, net=context.net, action=context.rule_action, headers=context.headers, rule_id=context.rule_id)
def retrieve_non_existent_subscription(context, server_id): context.server_id = server_id context.req = api_utils.retrieve_subscription(tenant_id=context.tenant_id, server_id=context.server_id, subscription_id=Utils.id_generator(10), headers=context.headers)