Beispiel #1
0
    def test_update_question_vote_chunk(self):
        # Reset the num_votes_past_week counts, I suspect the data gets
        # loaded before I disconnect the signal and they get zeroed out.
        q1 = question(save=True)
        questionvote(question=q1, save=True)
        q1.num_votes_past_week = 1
        q1.save()

        q2 = question(save=True)

        # Actually test the task.
        qs = Question.objects.all().order_by("-num_votes_past_week")
        eq_(q1.pk, qs[0].pk)

        questionvote(question=q2, save=True)
        questionvote(question=q2, save=True)
        qs = Question.uncached.all().order_by("-num_votes_past_week")
        eq_(q1.pk, qs[0].pk)

        update_question_vote_chunk([q.pk for q in qs])
        qs = Question.uncached.all().order_by("-num_votes_past_week")
        eq_(q2.pk, qs[0].pk)
Beispiel #2
0
    def test_update_question_vote_chunk(self):
        # Reset the num_votes_past_week counts, I suspect the data gets
        # loaded before I disconnect the signal and they get zeroed out.
        q = Question.objects.get(pk=3)
        q.num_votes_past_week = q.num_votes
        q.save()

        q = Question.objects.get(pk=2)
        q.num_votes_past_week = q.num_votes
        q.save()

        # Actually test the task.
        q1 = Question.objects.all().order_by('-num_votes_past_week')
        eq_(3, q1[0].pk)

        QuestionVote.objects.create(question=q1[1])
        q2 = Question.uncached.all().order_by('-num_votes_past_week')
        eq_(3, q2[0].pk)

        update_question_vote_chunk([q.pk for q in q1])
        q3 = Question.uncached.all().order_by('-num_votes_past_week')
        eq_(2, q3[0].pk)
Beispiel #3
0
    def test_update_question_vote_chunk(self):
        # Reset the num_votes_past_week counts, I suspect the data gets
        # loaded before I disconnect the signal and they get zeroed out.
        q1 = QuestionFactory()
        QuestionVoteFactory(question=q1)
        q1.num_votes_past_week = 1
        q1.save()

        q2 = QuestionFactory()

        # Actually test the task.
        qs = Question.objects.all().order_by("-num_votes_past_week")
        eq_(q1.pk, qs[0].pk)

        QuestionVoteFactory(question=q2)
        QuestionVoteFactory(question=q2)
        qs = Question.objects.all().order_by("-num_votes_past_week")
        eq_(q1.pk, qs[0].pk)

        update_question_vote_chunk([q.pk for q in qs])
        qs = Question.objects.all().order_by("-num_votes_past_week")
        eq_(q2.pk, qs[0].pk)
Beispiel #4
0
    def test_update_question_vote_chunk(self):
        # Reset the num_votes_past_week counts, I suspect the data gets
        # loaded before I disconnect the signal and they get zeroed out.
        q1 = question(save=True)
        questionvote(question=q1, save=True)
        q1.num_votes_past_week = 1
        q1.save()

        q2 = question(save=True)

        # Actually test the task.
        qs = Question.objects.all().order_by('-num_votes_past_week')
        eq_(q1.pk, qs[0].pk)

        questionvote(question=q2, save=True)
        questionvote(question=q2, save=True)
        qs = Question.uncached.all().order_by('-num_votes_past_week')
        eq_(q1.pk, qs[0].pk)

        update_question_vote_chunk([q.pk for q in qs])
        qs = Question.uncached.all().order_by('-num_votes_past_week')
        eq_(q2.pk, qs[0].pk)
Beispiel #5
0
    def test_update_question_vote_chunk(self):
        # Reset the num_votes_past_week counts, I suspect the data gets
        # loaded before I disconnect the signal and they get zeroed out.
        q1 = QuestionFactory()
        QuestionVoteFactory(question=q1)
        q1.num_votes_past_week = 1
        q1.save()

        q2 = QuestionFactory()

        # Actually test the task.
        qs = Question.objects.all().order_by('-num_votes_past_week')
        eq_(q1.pk, qs[0].pk)

        QuestionVoteFactory(question=q2)
        QuestionVoteFactory(question=q2)
        qs = Question.objects.all().order_by('-num_votes_past_week')
        eq_(q1.pk, qs[0].pk)

        update_question_vote_chunk([q.pk for q in qs])
        qs = Question.objects.all().order_by('-num_votes_past_week')
        eq_(q2.pk, qs[0].pk)