You can download this code by clicking the button below.
This code is now available for download.
This function randomly assigns a user role (admin, editor, viewer) from the Locust library to the passed user object.
Technology Stack : Locust
Code Type : Function
Code Difficulty : Intermediate
def random_user_role(user):
from locust import User
import random
roles = ['admin', 'editor', 'viewer']
return random.choice(roles)