Exemplo n.º 1
0
    def test_no_notification_on_update(self):
        """Saving an existing question does not watch it."""

        q = Question.objects.get(pk=1)
        assert not check_watch(Question, q.id, q.creator.email, 'reply')

        q.save()
        assert not check_watch(Question, q.id, q.creator.email, 'reply')
Exemplo n.º 2
0
    def test_watch_forum(self):
        """Watch then unwatch a forum."""
        self.client.login(username='******', password='******')
        f = Forum.objects.filter()[0]
        post(self.client, 'forums.watch_forum', {'watch': 'yes'},
             args=[f.slug])
        assert check_watch(Forum, f.id, 'user118577@nowhere',
                           'post'), 'Watch was not created'

        post(self.client, 'forums.watch_forum', {'watch': 'no'},
             args=[f.slug])
        assert not check_watch(Forum, f.id, 'user118577@nowhere',
                           'post'), 'Watch was not created'
Exemplo n.º 3
0
    def test_watch_set_unset(self):
        """Watch then unwatch a KB forum."""
        self.client.login(username='******', password='******')
        doc = Document.objects.filter()[0]
        post(self.client, 'wiki.discuss.watch_forum', {'watch': 'yes'},
             args=[doc.slug])
        assert check_watch(Document, doc.id, 'user118577@nowhere',
                           'post'), 'Watch was not created'

        post(self.client, 'wiki.discuss.watch_forum', {'watch': 'no'},
             args=[doc.slug])
        assert not check_watch(Document, doc.id, 'user118577@nowhere',
                           'post'), 'Watch was not created'
Exemplo n.º 4
0
 def test_unwatch(self):
     """Unwatch a question."""
     self.client.login(username='******', password='******')
     user = User.objects.get(username='******')
     create_watch(Question, self.question.id, user.email, 'solution')
     post(self.client, 'questions.unwatch', args=[self.question.id])
     assert not check_watch(Question, self.question.id, user.email,
                            'solution'), 'Watch was not destroyed'
Exemplo n.º 5
0
 def test_watch_solution(self):
     """Watch a question for solution."""
     self.client.logout()
     post(self.client, 'questions.watch',
          {'email': '*****@*****.**', 'event_type': 'solution'},
          args=[self.question.id])
     assert check_watch(Question, self.question.id, '*****@*****.**',
                        'solution'), 'Watch was not created'
Exemplo n.º 6
0
    def test_notification_created(self):
        """Creating a new question auto-watches it."""

        u = User.objects.get(pk=118533)
        q = Question(creator=u, title='foo', content='bar')
        q.save()

        assert check_watch(Question, q.id, u.email, 'reply')
Exemplo n.º 7
0
 def test_watch_replies_logged_in(self):
     """Watch a question for replies (logged in)."""
     self.client.login(username='******', password='******')
     user = User.objects.get(username='******')
     post(self.client, 'questions.watch',
          {'email': '*****@*****.**', 'event_type': 'reply'},
          args=[self.question.id])
     assert check_watch(Question, self.question.id, user.email,
                        'reply'), 'Watch was not created'
Exemplo n.º 8
0
 def test_check_watch_not_exist(self):
     """If a watch doesn't exist, check_watch() should return False."""
     assert not check_watch(Thread, 1000, '*****@*****.**', 'reply')
Exemplo n.º 9
0
 def test_check_watch_exists(self):
     """If a watch exists, check_watch() should return True."""
     w = EventWatch.objects.get(pk=1)
     assert check_watch(Thread, w.watch_id, w.email, 'reply')
Exemplo n.º 10
0
def is_watching_approved(user, locale):
    """Check if the user is watching approvals."""
    return check_watch(Document, None, user.email, 'approved', locale)
Exemplo n.º 11
0
def is_watching_locale(user, locale):
    """Check if the user is watching documents in the locale."""
    return check_watch(Document, None, user.email, 'ready_for_review', locale)