'Verify the escalate cronjob escalates the right questions.'

@mock.patch.object(kitsune.questions.tasks, 'submit_ticket')
def test_escalate_questions_cron(self, submit_ticket):

    questions_to_escalate = [QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10))), QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=50)))]
    fxos = ProductFactory(slug='firefox-os')
    q = QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)), product=fxos)
    questions_to_escalate.append(q)
    QuestionFactory()
    QuestionFactory(created=(datetime.now() - timedelta(hours=11)))
    QuestionFactory(created=(datetime.now() - timedelta(hours=21)))
    QuestionFactory(created=(datetime.now() - timedelta(hours=26)))
    QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)), locale='de')
    q = QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)))
    AnswerFactory(created=(datetime.now() - timedelta(hours=10)), question=q)
    AnswerFactory(created=(datetime.now() - timedelta(hours=1)), creator=q.creator, question=q)
    q = QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)))
    AnswerFactory(created=(datetime.now() - timedelta(hours=15)), creator=q.creator, question=q)
    q = QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)))
    q.tags.add(config.ESCALATE_TAG_NAME)
    q = QuestionFactory(creator__is_active=False, created=(datetime.now() - timedelta(hours=24, minutes=10)))
    tb = ProductFactory(slug='thunderbird')
    q = QuestionFactory(created=(datetime.now() - timedelta(hours=24, minutes=10)), product=tb)
    eq_(len(questions_to_escalate), escalate_questions())
