def test_needs_info(self): """Verify the needs_info queryset.""" q = QuestionFactory() # There should be no needs_info questions yet. eq_(0, Question.objects.needs_info().count()) # Tag a question and there should be one needs_info question. q.set_needs_info() eq_(1, Question.objects.needs_info().count()) # Remove tag and there shouldn't be any anymore. q.unset_needs_info() eq_(0, Question.objects.needs_info().count())
class TestQuestionReply(TestCaseBase): def setUp(self): u = UserFactory() self.client.login(username=u.username, password="******") self.question = QuestionFactory() def test_reply_to_spam_question(self): self.question.is_spam = True self.question.save() res = self.client.post( reverse("questions.reply", args=[self.question.id]), {"content": "The best reply evar!"}, ) eq_(res.status_code, 404) def test_needs_info(self): eq_(self.question.needs_info, False) res = self.client.post( reverse("questions.reply", args=[self.question.id]), { "content": "More info please", "needsinfo": "" }, ) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, True) def test_clear_needs_info(self): self.question.set_needs_info() eq_(self.question.needs_info, True) res = self.client.post( reverse("questions.reply", args=[self.question.id]), { "content": "More info please", "clear_needsinfo": "" }, ) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, False)
class TestQuestionReply(TestCaseBase): def setUp(self): u = UserFactory() self.client.login(username=u.username, password='******') self.question = QuestionFactory() def test_reply_to_spam_question(self): self.question.is_spam = True self.question.save() res = self.client.post( reverse('questions.reply', args=[self.question.id]), {'content': 'The best reply evar!'}) eq_(res.status_code, 404) def test_needs_info(self): eq_(self.question.needs_info, False) res = self.client.post( reverse('questions.reply', args=[self.question.id]), { 'content': 'More info please', 'needsinfo': '' }) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, True) def test_clear_needs_info(self): self.question.set_needs_info() eq_(self.question.needs_info, True) res = self.client.post( reverse('questions.reply', args=[self.question.id]), { 'content': 'More info please', 'clear_needsinfo': '' }) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, False)
class TestQuestionReply(TestCaseBase): def setUp(self): u = UserFactory() self.client.login(username=u.username, password='******') self.question = QuestionFactory() def test_reply_to_spam_question(self): self.question.is_spam = True self.question.save() res = self.client.post( reverse('questions.reply', args=[self.question.id]), {'content': 'The best reply evar!'}) eq_(res.status_code, 404) def test_needs_info(self): eq_(self.question.needs_info, False) res = self.client.post( reverse('questions.reply', args=[self.question.id]), {'content': 'More info please', 'needsinfo': ''}) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, True) def test_clear_needs_info(self): self.question.set_needs_info() eq_(self.question.needs_info, True) res = self.client.post( reverse('questions.reply', args=[self.question.id]), {'content': 'More info please', 'clear_needsinfo': ''}) eq_(res.status_code, 302) q = Question.objects.get(id=self.question.id) eq_(q.needs_info, False)