def test_responded(self): """Verify the responded queryset.""" # Create a question, there shouldn't be any responded yet. q = QuestionFactory() eq_(0, Question.objects.responded().count()) # Add an answer, there should be one responded. a = AnswerFactory(question=q) eq_(1, Question.objects.responded().count()) # Add an answer by the creator, there should be none responded. a = AnswerFactory(creator=q.creator, question=q) eq_(0, Question.objects.responded().count()) # Add another answer, there should be one responded. a = AnswerFactory(question=q) eq_(1, Question.objects.responded().count()) # Lock it, there should be none responded. q.is_locked = True q.save() eq_(0, Question.objects.responded().count()) # Unlock it and mark solved, there should be none responded. q.is_locked = False q.solution = a q.save() eq_(0, Question.objects.responded().count())
def test_editable(self): q = QuestionFactory() assert q.editable # unlocked/unarchived q.is_archived = True assert not q.editable # unlocked/archived q.is_locked = True assert not q.editable # locked/archived q.is_archived = False assert not q.editable # locked/unarchived q.is_locked = False assert q.editable # unlocked/unarchived