Beispiel #1
0
 def test_answer_authors(self):
     """Test answer authors returns correct users"""
     question = QuestionFactory()
     answer1 = AnswerFactory(question=question, user__username="******")
     answer2 = AnswerFactory(question=question, user__username="******")
     AnswerFactory(
         question=question, user__username="******", user__is_active=False
     )
     AnswerFactory(question=question, user=answer1.user)
     nose.tools.eq_(
         set(question.answer_authors()), set([answer1.user, answer2.user])
     )
Beispiel #2
0
    def test_report_spam(self):
        """Test reporting spam"""
        answer = AnswerFactory()
        url = reverse(
            "question-spam", kwargs={"model": "answer", "model_pk": answer.pk}
        )
        request = RequestFactory().get(url)
        request = mock_middleware(request)
        request.user = UserFactory()

        nose.tools.ok_(answer.user.is_active)
        report_spam(request, "answer", answer.pk)
        answer.refresh_from_db()
        nose.tools.ok_(answer.user.is_active)
        nose.tools.eq_(len(mail.outbox), 1)
Beispiel #3
0
 def test_answer_authors(self):
     """Test answer authors returns correct users"""
     question = QuestionFactory()
     answer1 = AnswerFactory(
         question=question,
         user__username='******',
     )
     answer2 = AnswerFactory(
         question=question,
         user__username='******',
     )
     AnswerFactory(
         question=question,
         user__username='******',
         user__is_active=False,
     )
     AnswerFactory(
         question=question,
         user=answer1.user,
     )
     nose.tools.eq_(
         set(question.answer_authors()),
         set([answer1.user, answer2.user]),
     )
Beispiel #4
0
 def test_digest_follow_questions(self):
     """Digests should include information on questions I follow."""
     # generate an action on a question that I follow
     question = QuestionFactory()
     follow(self.user, question, actor_only=False)
     other_user = UserFactory()
     answer = AnswerFactory(user=other_user, question=question)
     email = self.digest(user=self.user, interval=self.interval)
     eq_(email.activity["count"], 1, "There should be activity.")
     eq_(email.activity["questions"]["following"].first().action.actor, other_user)
     eq_(
         email.activity["questions"]["following"].first().action.action_object,
         answer,
     )
     eq_(email.activity["questions"]["following"].first().action.target, question)
     eq_(email.send(), 1, "The email should send.")
Beispiel #5
0
 def test_digest_user_questions(self):
     """Digests should include information on questions I asked."""
     # generate an action on a question the user asked
     question = QuestionFactory(user=self.user)
     other_user = UserFactory()
     AnswerFactory(user=other_user, question=question)
     # creating an answer _should_ have created a notification
     # so let's generate the email and see what happened
     email = self.digest(user=self.user, interval=self.interval)
     eq_(
         email.activity["count"],
         1,
         "There should be activity that is not user initiated.",
     )
     eq_(email.activity["questions"]["mine"].first().action.actor, other_user)
     eq_(email.activity["questions"]["mine"].first().action.verb, "answered")
     eq_(email.send(), 1, "The email should send.")
Beispiel #6
0
    def test_views(self):
        """Test views"""
        # we have no question fixtures
        # should move all fixtures to factories

        AnswerFactory()
        Site.objects.create(domain='www.muckrock.com')

        get_allowed(self.client, reverse('index'))
        get_allowed(self.client, '/sitemap.xml')
        get_allowed(self.client, '/sitemap-News.xml')
        get_allowed(self.client, '/sitemap-Jurisdiction.xml')
        get_allowed(self.client, '/sitemap-Agency.xml')
        get_allowed(self.client, '/sitemap-Question.xml')
        get_allowed(self.client, '/sitemap-FOIA.xml')
        get_allowed(self.client, '/news-sitemaps/index.xml')
        get_allowed(self.client, '/news-sitemaps/articles.xml')
        get_allowed(self.client, '/search/')