本文整理汇总了Python中kitsune.questions.events.QuestionReplyEvent类的典型用法代码示例。如果您正苦于以下问题:Python QuestionReplyEvent类的具体用法?Python QuestionReplyEvent怎么用?Python QuestionReplyEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuestionReplyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_autowatch_reply
def test_autowatch_reply(self, get_current):
"""
Tests the autowatch setting of users.
If a user has the setting turned on, they should get
notifications after posting in a thread for that thread. If they
have that setting turned off, they should not.
"""
get_current.return_value.domain = "testserver"
u = user(save=True)
t1 = question(save=True)
t2 = question(save=True)
assert not QuestionReplyEvent.is_notifying(u, t1)
assert not QuestionReplyEvent.is_notifying(u, t2)
self.client.login(username=u.username, password="testpass")
s = Setting.objects.create(user=u, name="questions_watch_after_reply", value="True")
data = {"content": "some content"}
post(self.client, "questions.reply", data, args=[t1.id])
assert QuestionReplyEvent.is_notifying(u, t1)
s.value = "False"
s.save()
post(self.client, "questions.reply", data, args=[t2.id])
assert not QuestionReplyEvent.is_notifying(u, t2)
示例2: test_autowatch_reply
def test_autowatch_reply(self, get_current):
"""
Tests the autowatch setting of users.
If a user has the setting turned on, they should get
notifications after posting in a thread for that thread. If they
have that setting turned off, they should not.
"""
get_current.return_value.domain = 'testserver'
u = UserFactory()
t1 = QuestionFactory()
t2 = QuestionFactory()
assert not QuestionReplyEvent.is_notifying(u, t1)
assert not QuestionReplyEvent.is_notifying(u, t2)
self.client.login(username=u.username, password='testpass')
s = Setting.objects.create(user=u, name='questions_watch_after_reply',
value='True')
data = {'content': 'some content'}
post(self.client, 'questions.reply', data, args=[t1.id])
assert QuestionReplyEvent.is_notifying(u, t1)
s.value = 'False'
s.save()
post(self.client, 'questions.reply', data, args=[t2.id])
assert not QuestionReplyEvent.is_notifying(u, t2)
示例3: test_no_notification_on_update
def test_no_notification_on_update(self):
"""Saving an existing question does not watch it."""
q = Question.objects.get(pk=1)
assert not QuestionReplyEvent.is_notifying(q.creator, q)
q.save()
assert not QuestionReplyEvent.is_notifying(q.creator, q)
示例4: setUp
def setUp(self):
p = profile()
p.save()
self.user = p.user
self.client.login(username=self.user.username, password='testpass')
self.question = question(creator=self.user, save=True)
QuestionReplyEvent.notify(self.user, self.question)
示例5: test_no_notification_on_update
def test_no_notification_on_update(self):
"""Saving an existing question does not watch it."""
q = question(save=True)
QuestionReplyEvent.stop_notifying(q.creator, q)
assert not QuestionReplyEvent.is_notifying(q.creator, q)
q.save()
assert not QuestionReplyEvent.is_notifying(q.creator, q)
示例6: test_notify_arbitrary_reply_to
def test_notify_arbitrary_reply_to(self):
"""
Test that notifications to the asker have a correct reply to field.
"""
watcher = user(save=True)
QuestionReplyEvent.notify(watcher, self.question)
self.makeAnswer()
notification = [m for m in mail.outbox if m.to == [watcher.email]][0]
# Headers should be compared case-insensitively.
headers = dict((k.lower(), v) for k, v in notification.extra_headers.items())
eq_("[email protected]", headers["reply-to"])
示例7: test_notify_anonymous_reply_to
def test_notify_anonymous_reply_to(self):
"""
Test that notifications to the asker have a correct reply to field.
"""
ANON_EMAIL = "[email protected]"
QuestionReplyEvent.notify(ANON_EMAIL, self.question)
self.makeAnswer()
notification = [m for m in mail.outbox if m.to == [ANON_EMAIL]][0]
# Headers should be compared case-insensitively.
headers = dict((k.lower(), v) for k, v in notification.extra_headers.items())
eq_("[email protected]", headers["reply-to"])
示例8: test_notify_arbitrary
def test_notify_arbitrary(self):
"""Test that arbitrary users are notified of new answers."""
watcher = UserFactory()
QuestionReplyEvent.notify(watcher, self.question)
self.makeAnswer()
# One for the asker's email, and one for the watcher's email.
eq_(2, len(mail.outbox))
notification = [m for m in mail.outbox if m.to == [watcher.email]][0]
eq_([watcher.email], notification.to)
eq_(u'Re: {0}'.format(self.question.title), notification.subject)
body = re.sub(r'auth=[a-zA-Z0-9%_-]+', 'auth=AUTH', notification.body)
starts_with(body, ANSWER_EMAIL.format(to_user=display_name(watcher), **self.format_args()))
示例9: test_notify_arbitrary
def test_notify_arbitrary(self):
"""Test that arbitrary users are notified of new answers."""
watcher = user(save=True)
QuestionReplyEvent.notify(watcher, self.question)
self.makeAnswer()
# One for the asker's email, and one for the watcher's email.
eq_(2, len(mail.outbox))
notification = [m for m in mail.outbox if m.to == [watcher.email]][0]
eq_([watcher.email], notification.to)
eq_("Re: {0}".format(self.question.title), notification.subject)
body = re.sub(r"auth=[a-zA-Z0-9%_-]+", "auth=AUTH", notification.body)
starts_with(body, ANSWER_EMAIL.format(to_user=watcher.username, **self.format_args()))
示例10: test_notify_anonymous
def test_notify_anonymous(self):
"""Test that anonymous users are notified of new answers."""
ANON_EMAIL = "[email protected]"
QuestionReplyEvent.notify(ANON_EMAIL, self.question)
self.makeAnswer()
# One for the asker's email, and one for the anonymous email.
eq_(2, len(mail.outbox))
notification = [m for m in mail.outbox if m.to == [ANON_EMAIL]][0]
eq_([ANON_EMAIL], notification.to)
eq_("Re: {0}".format(self.question.title), notification.subject)
body = re.sub(r"auth=[a-zA-Z0-9%_-]+", "auth=AUTH", notification.body)
starts_with(body, ANSWER_EMAIL_TO_ANONYMOUS.format(**self.format_args()))
示例11: test_notification_created
def test_notification_created(self):
"""Creating a new question auto-watches it for answers."""
u = user(save=True)
q = question(creator=u, title='foo', content='bar', save=True)
assert QuestionReplyEvent.is_notifying(u, q)
示例12: test_notification_created
def test_notification_created(self):
"""Creating a new question auto-watches it for answers."""
u = UserFactory()
q = QuestionFactory(creator=u, title='foo', content='bar')
assert QuestionReplyEvent.is_notifying(u, q)
示例13: save
def save(self, update=False, *args, **kwargs):
"""Override save method to take care of updated if requested."""
new = not self.id
if not new:
self.clear_cached_html()
if update:
self.updated = datetime.now()
super(Question, self).save(*args, **kwargs)
if new:
# Avoid circular import, events.py imports Question
from kitsune.questions.events import QuestionReplyEvent
# Authors should automatically watch their own questions.
QuestionReplyEvent.notify(self.creator, self)
示例14: test_notification_created
def test_notification_created(self):
"""Creating a new question auto-watches it for answers."""
u = User.objects.get(pk=118533)
q = Question(creator=u, title='foo', content='bar')
q.save()
assert QuestionReplyEvent.is_notifying(u, q)
示例15: test_notify_anonymous
def test_notify_anonymous(self):
"""Test that anonymous users are notified of new answers."""
ANON_EMAIL = '[email protected]'
QuestionReplyEvent.notify(ANON_EMAIL, self.question)
self.makeAnswer()
# One for the asker's email, and one for the anonymous email.
eq_(2, len(mail.outbox))
notification = [m for m in mail.outbox if m.to == [ANON_EMAIL]][0]
eq_([ANON_EMAIL], notification.to)
eq_("{0} commented on a Firefox question you're watching"
.format(self.answer.creator.username),
notification.subject)
body = re.sub(r'auth=[a-zA-Z0-9%_-]+', 'auth=AUTH', notification.body)
starts_with(body, ANSWER_EMAIL_TO_ANONYMOUS
.format(**self.format_args()))