当前位置: 首页>>代码示例>>Python>>正文


Python FacilityUser.get_or_initialize方法代码示例

本文整理汇总了Python中kalite.facility.models.FacilityUser.get_or_initialize方法的典型用法代码示例。如果您正苦于以下问题:Python FacilityUser.get_or_initialize方法的具体用法?Python FacilityUser.get_or_initialize怎么用?Python FacilityUser.get_or_initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kalite.facility.models.FacilityUser的用法示例。


在下文中一共展示了FacilityUser.get_or_initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_test

# 需要导入模块: from kalite.facility.models import FacilityUser [as 别名]
# 或者: from kalite.facility.models.FacilityUser import get_or_initialize [as 别名]
def load_test(request, nusers=None):
    """
    The principal purpose of this view is to allow the automated testing of multiple clients
    connected to the server at once, interacting in a way that is at least somewhat representative
    of normal user behaviour.

    As such, navigating to the loadtesting page on a client device will load an iframe which will
    then use Javascript to automate user interaction with the site. It will try to watch videos and
    do exercises in rapid succession in order to put strain on the server and associated network
    connections.

    So far the principal use for this has been testing with 30+ tablets connected over WiFi to a
    server and seeing if the server and wireless connection can handle the strain.
    """

    username = uuid.uuid4().hex[:12]

    # Make sure there's a facility
    if not Facility.objects.count():
        fac = Facility.objects.create(name="fac")
    fac = Facility.objects.all()[0]

    # Create the user
    (user, _) = FacilityUser.get_or_initialize(username=username, facility=fac)
    user.set_password(username)
    user.save()

    return {
        "pct_videos": request.GET.get("pct_videos", 0.3),
        "username": username,
    }
开发者ID:Aypak,项目名称:ka-lite,代码行数:33,代码来源:views.py

示例2: load_test

# 需要导入模块: from kalite.facility.models import FacilityUser [as 别名]
# 或者: from kalite.facility.models.FacilityUser import get_or_initialize [as 别名]
def load_test(request, nusers=None):
    global n_users_created

    if not n_users_created or n_users_created < int(request.GET.get("nusers", 1)):  # default 1, as before
        # It's either the first time, or time to add more

        # Make sure there's a facility
        if not Facility.objects.count():
            fac = Facility.objects.create(name="fac")
        fac = Facility.objects.all()[0]

        # Loop over all needed students
        while n_users_created < int(request.GET.get("nusers", 1)):
            n_users_created += 1
            unpw = "s%d" % n_users_created
            (user, _) = FacilityUser.get_or_initialize(username=unpw, facility=fac)
            user.set_password(unpw)
            user.save()

    return {
        "pct_videos": request.GET.get("pct_videos", 0.9),
        "pct_logout": request.GET.get("pct_logout", 0.0),
        "nusers": n_users_created,
    }
开发者ID:2flcastro,项目名称:ka-lite,代码行数:26,代码来源:views.py


注:本文中的kalite.facility.models.FacilityUser.get_or_initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。