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


Python Notification.query方法代码示例

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


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

示例1: test_create_notification

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create_notification(self):
        self.assertEqual([], Notification.query().all())
        self.assertEqual([], UserNotification.query().all())

        usrs = [self.u1, self.u2]
        notification = NotificationModel().create(created_by=self.u1,
                                           subject=u'subj', body=u'hi there',
                                           recipients=usrs)
        Session().commit()
        u1 = User.get(self.u1)
        u2 = User.get(self.u2)
        u3 = User.get(self.u3)
        notifications = Notification.query().all()
        self.assertEqual(len(notifications), 1)

        self.assertEqual(notifications[0].recipients, [u1, u2])
        self.assertEqual(notification.notification_id,
                         notifications[0].notification_id)

        unotification = UserNotification.query()\
            .filter(UserNotification.notification == notification).all()

        self.assertEqual(len(unotification), len(usrs))
        self.assertEqual(set([x.user.user_id for x in unotification]),
                         set(usrs))
开发者ID:break123,项目名称:rhodecode,代码行数:27,代码来源:test_notifications.py

示例2: test_create

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {'text': text}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain('''<div class="comments-number">%s comment '''
                             '''(0 inline)</div>''' % 1)

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]

        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/vcs_test_hg/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID)
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:34,代码来源:test_changeset_comments.py

示例3: test_create_inline

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create_inline(self):
        self.log_user()
        rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc"
        text = u"CommentOnRevision"
        f_path = "vcs/web/simplevcs/views/repository.py"
        line = "n1"

        params = {"text": text, "f_path": f_path, "line": line}
        response = self.app.post(
            url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params
        )
        # Test response...
        self.assertEqual(response.status, "302 Found")
        response.follow()

        response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain("""<div class="comments-number">0 comment(s)""" """ (%s inline)</div>""" % 1)
        response.mustcontain(
            """<div style="display:none" class="inline-comment-placeholder" """
            """path="vcs/web/simplevcs/views/repository.py" """
            """target_id="vcswebsimplevcsviewsrepositorypy">"""
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT)
        sbj = u"/vcs_test_hg/changeset/" "27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s" % ID
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
开发者ID:seacoastboy,项目名称:rhodecode,代码行数:36,代码来源:test_changeset_comments.py

示例4: test_create

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create(self):
        self.log_user()
        rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc"
        text = u"CommentOnRevision"

        params = {"text": text}
        response = self.app.post(
            url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params
        )
        # Test response...
        self.assertEqual(response.status, "302 Found")
        response.follow()

        response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        self.assertTrue("""<div class="comments-number">%s """ """comment(s) (0 inline)</div>""" % 1 in response.body)

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]

        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT)
        sbj = u"/vcs_test_hg/changeset/" "27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s" % ID
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
开发者ID:seacoastboy,项目名称:rhodecode,代码行数:30,代码来源:test_changeset_comments.py

示例5: test_notification_counter

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_notification_counter(self):
        self._clean_notifications()
        self.assertEqual([], Notification.query().all())
        self.assertEqual([], UserNotification.query().all())

        NotificationModel().create(created_by=self.u1,
                            subject=u'title', body=u'hi there_delete',
                            recipients=[self.u3, self.u1])
        Session().commit()

        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u1), 1)
        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u2), 0)
        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u3), 1)

        notification = NotificationModel().create(created_by=self.u1,
                                           subject=u'title', body=u'hi there3',
                                    recipients=[self.u3, self.u1, self.u2])
        Session().commit()

        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u1), 2)
        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u2), 1)
        self.assertEqual(NotificationModel()
                         .get_unread_cnt_for_user(self.u3), 2)
开发者ID:break123,项目名称:rhodecode,代码行数:30,代码来源:test_notifications.py

示例6: test_create_with_mention

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'@test_regular check CommentOnRevision'

        params = {'text':text}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain('''<div class="comments-number">%s '''
                             '''comment (0 inline)</div>''' % 1)

        self.assertEqual(Notification.query().count(), 2)
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular get's notification by @mention
        self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:28,代码来源:test_changeset_comments.py

示例7: test_delete_association

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_delete_association(self):

        self.assertEqual([], Notification.query().all())
        self.assertEqual([], UserNotification.query().all())

        notification = NotificationModel().create(created_by=self.u1,
                                           subject=u'title', body=u'hi there3',
                                    recipients=[self.u3, self.u1, self.u2])
        Session().commit()

        unotification = UserNotification.query()\
                            .filter(UserNotification.notification ==
                                    notification)\
                            .filter(UserNotification.user_id == self.u3)\
                            .scalar()

        self.assertEqual(unotification.user_id, self.u3)

        NotificationModel().delete(self.u3,
                                   notification.notification_id)
        Session().commit()

        u3notification = UserNotification.query()\
                            .filter(UserNotification.notification ==
                                    notification)\
                            .filter(UserNotification.user_id == self.u3)\
                            .scalar()

        self.assertEqual(u3notification, None)

        # notification object is still there
        self.assertEqual(Notification.query().all(), [notification])

        #u1 and u2 still have assignments
        u1notification = UserNotification.query()\
                            .filter(UserNotification.notification ==
                                    notification)\
                            .filter(UserNotification.user_id == self.u1)\
                            .scalar()
        self.assertNotEqual(u1notification, None)
        u2notification = UserNotification.query()\
                            .filter(UserNotification.notification ==
                                    notification)\
                            .filter(UserNotification.user_id == self.u2)\
                            .scalar()
        self.assertNotEqual(u2notification, None)
开发者ID:break123,项目名称:rhodecode,代码行数:48,代码来源:test_notifications.py

示例8: setUp

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def setUp(self):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        for x in Notification.query().all():
            Session().delete(x)
        Session().commit()
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:10,代码来源:test_changeset_comments.py

示例9: tearDown

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def tearDown(self):
        for x in ChangesetComment.query().all():
            self.Session.delete(x)
        self.Session.commit()

        for x in Notification.query().all():
            self.Session.delete(x)
        self.Session.commit()
开发者ID:seacoastboy,项目名称:rhodecode,代码行数:10,代码来源:test_changeset_comments.py

示例10: test_delete_notifications

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_delete_notifications(self):
        self.assertEqual([], Notification.query().all())
        self.assertEqual([], UserNotification.query().all())

        notification = NotificationModel().create(created_by=self.u1,
                                           subject=u'title', body=u'hi there3',
                                    recipients=[self.u3, self.u1, self.u2])
        Session().commit()
        notifications = Notification.query().all()
        self.assertTrue(notification in notifications)

        Notification.delete(notification.notification_id)
        Session().commit()

        notifications = Notification.query().all()
        self.assertFalse(notification in notifications)

        un = UserNotification.query().filter(UserNotification.notification
                                             == notification).all()
        self.assertEqual(un, [])
开发者ID:break123,项目名称:rhodecode,代码行数:22,代码来源:test_notifications.py

示例11: test_create_inline

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {'text': text, 'f_path': f_path, 'line': line}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        #test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">0 comments'''
            ''' (%s inline)</div>''' % 1
        )
        response.mustcontain(
            '''<div style="display:none" class="inline-comment-placeholder" '''
            '''path="vcs/web/simplevcs/views/repository.py" '''
            '''target_id="vcswebsimplevcsviewsrepositorypy">'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/vcs_test_hg/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID)
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:42,代码来源:test_changeset_comments.py

示例12: test_user_notifications

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_user_notifications(self):
        self.assertEqual([], Notification.query().all())
        self.assertEqual([], UserNotification.query().all())

        notification1 = NotificationModel().create(created_by=self.u1,
                                            subject=u'subj', body=u'hi there1',
                                            recipients=[self.u3])
        Session().commit()
        notification2 = NotificationModel().create(created_by=self.u1,
                                            subject=u'subj', body=u'hi there2',
                                            recipients=[self.u3])
        Session().commit()
        u3 = Session().query(User).get(self.u3)

        self.assertEqual(sorted([x.notification for x in u3.notifications]),
                         sorted([notification2, notification1]))
开发者ID:break123,项目名称:rhodecode,代码行数:18,代码来源:test_notifications.py

示例13: test_create_with_mention

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def test_create_with_mention(self):
        self.log_user()

        rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc"
        text = u"@test_regular check CommentOnRevision"

        params = {"text": text}
        response = self.app.post(
            url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params
        )
        # Test response...
        self.assertEqual(response.status, "302 Found")
        response.follow()

        response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        self.assertTrue("""<div class="comments-number">%s """ """comment(s) (0 inline)</div>""" % 1 in response.body)

        self.assertEqual(Notification.query().count(), 2)
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular get's notification by @mention
        self.assertEqual(sorted(users), [u"test_admin", u"test_regular"])
开发者ID:seacoastboy,项目名称:rhodecode,代码行数:26,代码来源:test_changeset_comments.py

示例14: _clean_notifications

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
    def _clean_notifications(self):
        for n in Notification.query().all():
            Session().delete(n)

        Session().commit()
        self.assertEqual(Notification.query().all(), [])
开发者ID:break123,项目名称:rhodecode,代码行数:8,代码来源:test_notifications.py

示例15: tearDown

# 需要导入模块: from rhodecode.model.db import Notification [as 别名]
# 或者: from rhodecode.model.db.Notification import query [as 别名]
 def tearDown(self):
     for n in Notification.query().all():
         inst = Notification.get(n.notification_id)
         self.Session().delete(inst)
     self.Session().commit()
开发者ID:break123,项目名称:rhodecode,代码行数:7,代码来源:test_admin_notifications.py


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