コード例 #1
0
ファイル: test_managers.py プロジェクト: zu83/kitsune
    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())
コード例 #2
0
ファイル: test_managers.py プロジェクト: 1234-/kitsune
    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())
コード例 #3
0
ファイル: test_models.py プロジェクト: 1234-/kitsune
 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
コード例 #4
0
ファイル: test_models.py プロジェクト: rootmeb/kitsune
 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