• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python db_utils.create_submission函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weasyl.test.db_utils.create_submission函数的典型用法代码示例。如果您正苦于以下问题:Python create_submission函数的具体用法?Python create_submission怎么用?Python create_submission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_blocked_tag

    def test_blocked_tag(self):
        user1 = db_utils.create_user()
        user2 = db_utils.create_user()

        # submission s1 has a walrus in it, but user2 does not like walruses
        s1 = db_utils.create_submission(user1, rating=ratings.GENERAL.code)
        tag1 = db_utils.create_tag("walrus")
        db_utils.create_submission_tag(tag1, s1)
        db_utils.create_blocktag(user2, tag1, ratings.GENERAL.code)
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # submission s2 has a penguin in it. user2 does not want to see penguins in
        # adult circumstances, but s2 is general, so visibility is OK
        s2 = db_utils.create_submission(user1, rating=ratings.GENERAL.code)
        tag2 = db_utils.create_tag("penguin")
        db_utils.create_submission_tag(tag2, s2)
        db_utils.create_blocktag(user2, tag2, ratings.EXPLICIT.code)
        self.assertEqual(
            1, len(submission.select_list(user2, ratings.EXPLICIT.code, 10)))

        # submission s3 has penguins on it in adult situations, but User2
        # is okay with that if it's one of User2's own submissions.
        s3 = db_utils.create_submission(user2, rating=ratings.EXPLICIT.code)
        db_utils.create_submission_tag(tag2, s3)
        self.assertEqual(
            2, len(submission.select_list(user2, ratings.EXPLICIT.code, 10)))
开发者ID:0x15,项目名称:weasyl,代码行数:27,代码来源:test_submission.py


示例2: test_friends_only

    def test_friends_only(self):
        user1 = db_utils.create_user()
        user2 = db_utils.create_user()
        db_utils.create_submission(user1, rating=ratings.GENERAL.code, settings=CharSettings({'friends-only'}, {}, {}))

        # poster can view their submission
        self.assertEqual(
            1, len(submission.select_list(user1, ratings.GENERAL.code, 10)))

        # but a non-friend or a non-logged in user cannot
        self.assertEqual(
            0, len(submission.select_list(None, ratings.GENERAL.code, 10)))
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # user with a pending friendship cannot view
        db_utils.create_friendship(user1, user2, settings=CharSettings({'pending'}, {}, {}))
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # but a friend can
        d.sessionmaker().query(users.Friendship).delete()
        db_utils.create_friendship(user1, user2)
        self.assertEqual(
            1, len(submission.select_list(user2, ratings.GENERAL.code, 10)))
开发者ID:0x15,项目名称:weasyl,代码行数:25,代码来源:test_submission.py


示例3: test_search_blocked_tags

def test_search_blocked_tags(db, rating, block_rating):
    owner = db_utils.create_user()
    viewer = db_utils.create_user()

    allowed_tag = db_utils.create_tag('walrus')
    blocked_tag = db_utils.create_tag('penguin')

    db_utils.create_blocktag(viewer, blocked_tag, block_rating.code)

    s1 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(allowed_tag, s1)
    db_utils.create_submission_tag(blocked_tag, s1)

    s2 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(allowed_tag, s2)

    s3 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(blocked_tag, s3)

    def check(term, n_results):
        results, _, _ = search.select(
            search=search.Query.parse(term, 'submit'),
            userid=viewer, rating=ratings.EXPLICIT.code, limit=100,
            cat=None, subcat=None, within='', backid=None, nextid=None)

        assert len(results) == n_results

    if rating < block_rating:
        check(u'walrus', 2)
        check(u'penguin', 2)
    else:
        check(u'walrus', 1)
        check(u'penguin', 0)
开发者ID:charmander,项目名称:weasyl,代码行数:33,代码来源:test_search.py


示例4: test_block_user_homepage

def test_block_user_homepage(app):
    """
    Assert that changes to blocked users apply to the home page immediately.
    """
    submitting_user1 = db_utils.create_user()
    submitting_user2 = db_utils.create_user()
    viewing_user = db_utils.create_user()

    db_utils.create_submission(submitting_user1, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission(submitting_user2, rating=ratings.GENERAL.code, subtype=1010)

    cookie = db_utils.create_session(viewing_user)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2

    app.post('/ignoreuser',
             {'userid': str(submitting_user1), 'action': 'ignore'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 1

    app.post('/ignoreuser',
             {'userid': str(submitting_user1), 'action': 'unignore'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2
开发者ID:Weasyl,项目名称:weasyl,代码行数:29,代码来源:test_blacklist.py


示例5: test_blacklist_homepage

def test_blacklist_homepage(app):
    """
    Assert that changes to the blacklist apply to the home page immediately.
    """
    submitting_user = db_utils.create_user()
    viewing_user = db_utils.create_user()
    tag1 = db_utils.create_tag('walrus')
    tag2 = db_utils.create_tag('penguin')

    s1 = db_utils.create_submission(submitting_user, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission_tag(tag1, s1)

    s2 = db_utils.create_submission(submitting_user, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission_tag(tag2, s2)

    cookie = db_utils.create_session(viewing_user)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2

    app.post('/manage/tagfilters',
             {'title': 'walrus', 'rating': str(ratings.GENERAL.code), 'do': 'create'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 1

    app.post('/manage/tagfilters',
             {'title': 'walrus', 'rating': str(ratings.GENERAL.code), 'do': 'remove'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2
开发者ID:Weasyl,项目名称:weasyl,代码行数:33,代码来源:test_blacklist.py


示例6: test_feature_page_filter

 def test_feature_page_filter(self):
     user1 = db_utils.create_user()
     folder = db_utils.create_folder(
         user1, settings=CharSettings({"featured-filter"}, {}, {}))
     db_utils.create_submissions(9, user1, ratings.GENERAL.code)
     db_utils.create_submission(user1, ratings.GENERAL.code, folderid=folder)
     self.assertEqual(
         10, len(submission.select_list(user1, ratings.GENERAL.code, 10)))
     self.assertEqual(
         1, len(submission.select_list(user1, ratings.GENERAL.code, 10,
                                       featured_filter=True)))
开发者ID:0x15,项目名称:weasyl,代码行数:11,代码来源:test_submission.py


示例7: test_ratings_twittercard

    def test_ratings_twittercard(self):
        user = db_utils.create_user()

        sub1 = db_utils.create_submission(user, rating=ratings.GENERAL.code)
        sub2 = db_utils.create_submission(user, rating=ratings.MATURE.code)
        sub3 = db_utils.create_submission(user, rating=ratings.EXPLICIT.code)

        card1 = submission.twitter_card(sub1)
        card2 = submission.twitter_card(sub2)
        card3 = submission.twitter_card(sub3)

        self.assertNotEqual('This image is rated 18+ and only viewable on weasyl.com', card1['description'])
        self.assertEqual('This image is rated 18+ and only viewable on weasyl.com', card2['description'])
        self.assertEqual('This image is rated 18+ and only viewable on weasyl.com', card3['description'])
开发者ID:Syfaro,项目名称:weasyl,代码行数:14,代码来源:test_submission.py


示例8: test_ignored_user

 def test_ignored_user(self):
     user1 = db_utils.create_user()
     user2 = db_utils.create_user()
     db_utils.create_submission(user1, rating=ratings.GENERAL.code)
     # can view the submission
     self.assertEqual(
         1, len(submission.select_list(user2, ratings.GENERAL.code, 10)))
     # user2 blocks user1
     db_utils.create_ignoreuser(user2, user1)
     # user2 can no longer view the submission
     self.assertEqual(
         0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))
     # but a non-logged in user can
     self.assertEqual(
         1, len(submission.select_list(None, ratings.GENERAL.code, 10)))
开发者ID:0x15,项目名称:weasyl,代码行数:15,代码来源:test_submission.py


示例9: test_attempt_setting_tags_when_some_tags_have_been_restricted

def test_attempt_setting_tags_when_some_tags_have_been_restricted():
    """
    Verify that tags are excluded from being added to a submission's tags if the tag is restricted
    """
    userid_owner = db_utils.create_user()
    userid_tag_adder = db_utils.create_user()
    journalid = db_utils.create_journal(userid_owner)
    charid = db_utils.create_character(userid_owner)
    submitid = db_utils.create_submission(userid_owner)
    restricted_tag = searchtag.parse_restricted_tags("pearl")
    searchtag.edit_user_tag_restrictions(userid_owner, restricted_tag)

    searchtag.associate(userid_tag_adder, tags, submitid=submitid)
    searchtag.associate(userid_tag_adder, tags, charid=charid)
    searchtag.associate(userid_tag_adder, tags, journalid=journalid)

    # Verify that the "pearl" tag was not added
    submission_tags = searchtag.select(submitid=submitid)
    assert tags_two == set(submission_tags)

    character_tags = searchtag.select(charid=charid)
    assert tags_two == set(character_tags)

    journal_tags = searchtag.select(journalid=journalid)
    assert tags_two == set(journal_tags)
开发者ID:Syfaro,项目名称:weasyl,代码行数:25,代码来源:test_associate.py


示例10: test_search_pagination

def test_search_pagination(db):
    owner = db_utils.create_user()
    submissions = [db_utils.create_submission(owner, rating=ratings.GENERAL.code) for i in range(30)]
    tag = db_utils.create_tag('penguin')
    search_query = search.Query.parse(u'penguin', 'submit')

    for submission in submissions:
        db_utils.create_submission_tag(tag, submission)

    result, next_count, back_count = search.select(
        search=search_query,
        userid=owner, rating=ratings.EXPLICIT.code, limit=_page_limit,
        cat=None, subcat=None, within='', backid=None, nextid=None)

    assert back_count == 0
    assert next_count == search.COUNT_LIMIT
    assert [item['submitid'] for item in result] == submissions[:-_page_limit - 1:-1]

    result, next_count, back_count = search.select(
        search=search_query,
        userid=owner, rating=ratings.EXPLICIT.code, limit=_page_limit,
        cat=None, subcat=None, within='', backid=None, nextid=submissions[-_page_limit])

    assert back_count == _page_limit
    assert next_count == search.COUNT_LIMIT
    assert [item['submitid'] for item in result] == submissions[-_page_limit - 1:-2 * _page_limit - 1:-1]

    result, next_count, back_count = search.select(
        search=search_query,
        userid=owner, rating=ratings.EXPLICIT.code, limit=_page_limit,
        cat=None, subcat=None, within='', backid=submissions[_page_limit - 1], nextid=None)

    assert back_count == search.COUNT_LIMIT
    assert next_count == _page_limit
    assert [item['submitid'] for item in result] == submissions[2 * _page_limit - 1:_page_limit - 1:-1]
开发者ID:charmander,项目名称:weasyl,代码行数:35,代码来源:test_search.py


示例11: test_retag_no_owner_remove

    def test_retag_no_owner_remove(self):
        config = CharSettings({'disallow-others-tag-removal'}, {}, {})
        owner = db_utils.create_user(config=config)
        tagger = db_utils.create_user()
        s = db_utils.create_submission(owner, rating=ratings.GENERAL.code)

        searchtag.associate(owner, {'orange'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['orange'])

        searchtag.associate(tagger, {'apple', 'tomato'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['apple', 'orange', 'tomato'])

        searchtag.associate(tagger, {'tomato'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['orange', 'tomato'])

        searchtag.associate(owner, {'kale'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['kale'])
开发者ID:Syfaro,项目名称:weasyl,代码行数:25,代码来源:test_submission.py


示例12: test_moderators_and_above_can_add_restricted_tags_successfully

def test_moderators_and_above_can_add_restricted_tags_successfully(monkeypatch):
    """
    Moderators (and admins, technical, and directors) can add restricted tags to content.
    Developers are not included in this test, as they are for all intents and purposes just
      normal user accounts.
    """
    userid_owner = db_utils.create_user()
    mod_tag_adder = db_utils.create_user()
    monkeypatch.setattr(staff, 'MODS', frozenset([mod_tag_adder]))
    journalid = db_utils.create_journal(userid_owner)
    charid = db_utils.create_character(userid_owner)
    submitid = db_utils.create_submission(userid_owner)
    restricted_tag = searchtag.parse_restricted_tags("pearl")
    searchtag.edit_user_tag_restrictions(userid_owner, restricted_tag)

    searchtag.associate(mod_tag_adder, tags, submitid=submitid)
    searchtag.associate(mod_tag_adder, tags, charid=charid)
    searchtag.associate(mod_tag_adder, tags, journalid=journalid)

    # Verify that all tags were added successfully. 'pearl' is restricted.
    submission_tags = searchtag.select(submitid=submitid)
    assert tags == set(submission_tags)

    character_tags = searchtag.select(charid=charid)
    assert tags == set(character_tags)

    journal_tags = searchtag.select(journalid=journalid)
    assert tags == set(journal_tags)
开发者ID:Syfaro,项目名称:weasyl,代码行数:28,代码来源:test_associate.py


示例13: test_simple_submission

 def test_simple_submission(self):
     """
     Posting a submission should create notifications for all watchers.
     """
     s = db_utils.create_submission(self.owner)
     welcome.submission_insert(self.owner, s)
     self.assertEquals(1, self._notification_count(self.friend))
     self.assertEquals(1, self._notification_count(self.nonfriend))
     self.assertEquals(1, self._notification_count(self.ignored))
开发者ID:0x15,项目名称:weasyl,代码行数:9,代码来源:test_submission.py


示例14: test_friends_only_submission

 def test_friends_only_submission(self):
     """
     Submissions uploaded as friends-only should be visible only to friends.
     """
     s = db_utils.create_submission(
         self.owner,
         settings=CharSettings({'friends-only'}, {}, {}))
     welcome.submission_insert(self.owner, s, settings='f')
     self.assertEquals(1, self._notification_count(self.friend))
     self.assertEquals(0, self._notification_count(self.nonfriend))
     self.assertEquals(0, self._notification_count(self.ignored))
开发者ID:0x15,项目名称:weasyl,代码行数:11,代码来源:test_submission.py


示例15: create_commish_searchable_user

def create_commish_searchable_user(username, commish_status='o', commishclass='badge',
                                   minprice="10.00", maxprice="15.00", currency='', submittime=arrow.get(1)):
    user = db_utils.create_user(username=username)
    profile.edit_profile_settings(
        userid=user,
        set_commission=profile.get_exchange_setting(profile.EXCHANGE_TYPE_COMMISSION, commish_status)
    )
    commishinfo.create_commission_class(user, commishclass)
    classid = commishinfo.select_list(user)["class"][0]["classid"]
    assert classid

    price = orm.CommishPrice()
    price.title = "test price"
    price.classid = classid
    price.amount_min = commishinfo.parse_currency(minprice)
    price.amount_max = commishinfo.parse_currency(maxprice)
    commishinfo.create_price(user, price, currency)

    db_utils.create_submission(user, unixtime=submittime)

    return user
开发者ID:Syfaro,项目名称:weasyl,代码行数:21,代码来源:test_marketplace.py


示例16: test_recently_popular

    def test_recently_popular(self):
        owner = db_utils.create_user()
        now = arrow.now()

        sub1 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=6))
        sub2 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=4))
        sub3 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=2))
        sub4 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now)
        tag = db_utils.create_tag(u'tag')

        for s in [sub1, sub2, sub3, sub4]:
            db_utils.create_submission_tag(tag, s)

        for i in range(100):
            favoriter = db_utils.create_user()
            db_utils.create_favorite(favoriter, sub2, 's', unixtime=now)

        recently_popular = submission.select_recently_popular()

        self.assertEqual(
            [item['submitid'] for item in recently_popular],
            [sub2, sub4, sub3, sub1])
开发者ID:Syfaro,项目名称:weasyl,代码行数:22,代码来源:test_submission.py


示例17: test_filters

    def test_filters(self):
        # Test filters of the following:
        # userid, folderid, category, hidden
        user1 = db_utils.create_user()
        user2 = db_utils.create_user()
        folder = db_utils.create_folder(user1)
        db_utils.create_submission(user1, rating=ratings.GENERAL.code, folderid=folder)
        db_utils.create_submission(user1, rating=ratings.GENERAL.code, subtype=1010)
        db_utils.create_submission(user1, rating=ratings.GENERAL.code, settings=CharSettings({'hidden'}, {}, {}))
        db_utils.create_submission(user2, rating=ratings.GENERAL.code)

        self.assertEqual(3, len(submission.select_list(user1, ratings.EXPLICIT.code, 10)))
        self.assertEqual(1, len(submission.select_list(user1, ratings.EXPLICIT.code, 10, otherid=user2)))
        self.assertEqual(1, len(submission.select_list(user1, ratings.EXPLICIT.code, 10, folderid=folder)))
        self.assertEqual(1, len(submission.select_list(user1, ratings.EXPLICIT.code, 10, subcat=1010)))
开发者ID:0x15,项目名称:weasyl,代码行数:15,代码来源:test_submission.py


示例18: test_ratings_twittercard

    def test_ratings_twittercard(self):
        # For tests, this isn't set. absolutify_url requires it,
        # so this test would fail if it wasn't set.
        web.ctx.realhome = 'https://lo.weasyl.com:8443'

        user = db_utils.create_user()

        sub1 = db_utils.create_submission(user, rating=ratings.GENERAL.code)
        sub2 = db_utils.create_submission(user, rating=ratings.MODERATE.code)
        sub3 = db_utils.create_submission(user, rating=ratings.MATURE.code)
        sub4 = db_utils.create_submission(user, rating=ratings.EXPLICIT.code)

        card1 = submission.twitter_card(sub1)
        card2 = submission.twitter_card(sub2)
        card3 = submission.twitter_card(sub3)
        card4 = submission.twitter_card(sub4)

        self.assertNotEqual('This image is rated 18+ and only viewable on weasyl.com', card1['description'])
        self.assertNotEqual('This image is rated 18+ and only viewable on weasyl.com', card2['description'])
        self.assertEqual('This image is rated 18+ and only viewable on weasyl.com', card3['description'])
        self.assertEqual('This image is rated 18+ and only viewable on weasyl.com', card4['description'])

        # Delete this so it cannot interfere with other things.
        del web.ctx.realhome
开发者ID:dzamie,项目名称:weasyl,代码行数:24,代码来源:test_submission.py


示例19: test_submission_search

def test_submission_search(db, term, n_results):
    user = db_utils.create_user()
    tag1 = db_utils.create_tag('walrus')
    tag2 = db_utils.create_tag('penguin')

    s1 = db_utils.create_submission(user, rating=ratings.GENERAL.code)
    db_utils.create_submission_tag(tag1, s1)
    db_utils.create_submission_tag(tag2, s1)

    s2 = db_utils.create_submission(user, rating=ratings.EXPLICIT.code)
    db_utils.create_submission_tag(tag1, s2)

    s3 = db_utils.create_submission(user, rating=ratings.GENERAL.code)
    db_utils.create_submission_tag(tag2, s3)

    s4 = db_utils.create_submission(user, rating=ratings.GENERAL.code)
    db_utils.create_submission_tag(tag2, s4)

    results, _, _ = search.select(
        search=search.Query.parse(term, 'submit'),
        userid=user, rating=ratings.EXPLICIT.code, limit=100,
        cat=None, subcat=None, within='', backid=None, nextid=None)

    assert len(results) == n_results
开发者ID:dzamie,项目名称:weasyl,代码行数:24,代码来源:test_search.py


示例20: test_submission_becomes_friends_only

    def test_submission_becomes_friends_only(self):
        """
        Submissions becoming friends-only should be removed from non-friends'
        notification lists.
        """
        # Initial behavior should match with normal.
        s = db_utils.create_submission(self.owner)
        welcome.submission_insert(self.owner, s)
        self.assertEquals(1, self._notification_count(self.friend))
        self.assertEquals(1, self._notification_count(self.nonfriend))
        self.assertEquals(1, self._notification_count(self.ignored))

        welcome.submission_became_friends_only(s, self.owner)
        self.assertEquals(1, self._notification_count(self.friend))
        self.assertEquals(0, self._notification_count(self.nonfriend))
        self.assertEquals(0, self._notification_count(self.ignored))
开发者ID:0x15,项目名称:weasyl,代码行数:16,代码来源:test_submission.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db_utils.create_user函数代码示例发布时间:2022-05-26
下一篇:
Python db_utils.create_session函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap