Пример #1
0
def test_commish_search_invalid():
    # searcher
    u1 = db_utils.create_user(username="******")

    # user not open for commissions, but with submissions and commish classes defined
    create_commish_searchable_user("u2", commish_status='c')

    # user open for commission but without any commish classes
    u3 = create_commish_searchable_user("u3")
    classid = commishinfo.select_list(u3)["class"][0]["classid"]
    commishinfo.remove_class(u3, classid)

    # user meets all requirements, but is suspended
    u4 = create_commish_searchable_user("u4")
    db_utils.create_suspenduser(u4, "", d.get_time() + 604800)

    # user meets all requirements, but is banned
    u5 = create_commish_searchable_user("u5")
    db_utils.create_banuser(u5, "")

    # user meets all requirements, but is ignored by searching user
    u6 = create_commish_searchable_user("u6")
    db_utils.create_ignoreuser(u1, u6)

    results = commishinfo.select_commissionable(userid=u1,
                                                limit=10,
                                                offset=0,
                                                q="",
                                                commishclass="",
                                                min_price=None,
                                                max_price=None,
                                                currency='')
    assert not results
Пример #2
0
def test_commish_search(args, result_order):
    # searcher
    u1 = db_utils.create_user(username="******")

    # user open for commissions
    create_commish_searchable_user("u2", submittime=arrow.now())

    # user sometimes open for commissions (should behave same as above)
    create_commish_searchable_user("u3", commish_status='s',
                                   submittime=arrow.now() - datetime.timedelta(days=1))

    # user open for commissions, with blacklisted tags
    u4 = create_commish_searchable_user("u4", submittime=arrow.now() - datetime.timedelta(days=2))
    searchtag.associate(u4, optout_tags_userid=u4, tags={'cat'})

    # user with a different commish class and a preference tag
    u5 = create_commish_searchable_user("u5", commishclass="sketch",
                                        submittime=arrow.now() - datetime.timedelta(days=3))
    searchtag.associate(u5, preferred_tags_userid=u5, tags={'cat'})

    # user with a different price
    create_commish_searchable_user("u6", minprice="100.0", maxprice="100.0",
                                   submittime=arrow.now() - datetime.timedelta(days=4))

    results = commishinfo.select_commissionable(userid=u1,
                                                limit=10,
                                                offset=0,
                                                **args)
    rids = [r['username'] for r in results]
    assert rids == result_order
Пример #3
0
def test_commish_search_invalid():
    # searcher
    u1 = db_utils.create_user(username="******")

    # user not open for commissions, but with submissions and commish classes defined
    create_commish_searchable_user("u2", commish_status='c')

    # user open for commission but without any commish classes
    u3 = create_commish_searchable_user("u3")
    classid = commishinfo.select_list(u3)["class"][0]["classid"]
    commishinfo.remove_class(u3, classid)

    # user meets all requirements, but is suspended
    u4 = create_commish_searchable_user("u4")
    db_utils.create_suspenduser(u4, "", arrow.now() + datetime.timedelta(days=7))

    # user meets all requirements, but is banned
    u5 = create_commish_searchable_user("u5")
    db_utils.create_banuser(u5, "")

    # user meets all requirements, but is ignored by searching user
    u6 = create_commish_searchable_user("u6")
    db_utils.create_ignoreuser(u1, u6)

    results = commishinfo.select_commissionable(userid=u1,
                                                limit=10,
                                                offset=0,
                                                q="",
                                                commishclass="",
                                                min_price=None,
                                                max_price=None,
                                                currency='')
    assert not results
Пример #4
0
def search_(request):
    form = request.web_input(q="",
                             min="",
                             max="",
                             currency="",
                             pc="",
                             c="",
                             o="")
    limit = 30
    offset = define.get_int(form.o)
    commishclass = form.pc if form.pc else form.c
    commishclass = commishclass.lower()

    results = commishinfo.select_commissionable(
        request.userid,
        form.q,
        commishclass,
        commishinfo.parse_currency(form.min),
        commishinfo.parse_currency(form.max),
        form.currency,
        offset,
        limit * 2,
    )
    rcount = len(results)
    results = results[0:limit]
    media.populate_with_user_media(results)
    prev_index = None if offset == 0 else offset - limit if offset - limit > 0 else 0
    next_index = offset + limit if rcount - limit > 0 else None
    return Response(
        define.webpage(request.userid, "etc/marketplace.html", [
            results, form, commishinfo.CURRENCY_CHARMAP,
            commishinfo.PRESET_COMMISSION_CLASSES, prev_index, next_index
        ]))
Пример #5
0
def test_commish_search(args, result_order):
    # searcher
    u1 = db_utils.create_user(username="******")

    # user open for commissions
    create_commish_searchable_user("u2", submittime=arrow.now())

    # user sometimes open for commissions (should behave same as above)
    create_commish_searchable_user("u3", commish_status='s',
                                   submittime=arrow.now() - datetime.timedelta(days=1))

    # user open for commissions, with blacklisted tags
    u4 = create_commish_searchable_user("u4", submittime=arrow.now() - datetime.timedelta(days=2))
    searchtag.associate(u4, optout_tags_userid=u4, tags={'cat'})

    # user with a different commish class and a preference tag
    u5 = create_commish_searchable_user("u5", commishclass="sketch",
                                        submittime=arrow.now() - datetime.timedelta(days=3))
    searchtag.associate(u5, preferred_tags_userid=u5, tags={'cat'})

    # user with a different price
    create_commish_searchable_user("u6", minprice="100.0", maxprice="100.0",
                                   submittime=arrow.now() - datetime.timedelta(days=4))

    results = commishinfo.select_commissionable(userid=u1,
                                                limit=10,
                                                offset=0,
                                                **args)
    rids = [r['username'] for r in results]
    assert rids == result_order