'Test locale filtering of questions API call.'

def test_questions_by_locale(self):

    q = QuestionFactory(locale='en-US')
    a = AnswerFactory(question=q)
    q.solution = a
    q.save()
    q = QuestionFactory(locale='en-US')
    AnswerFactory(question=q)
    QuestionFactory(locale='en-US')
    QuestionFactory(locale='pt-BR')
    r = self._get_api_result('api.kpi.questions')
    eq_(r['objects'][0]['solved'], 1)
    eq_(r['objects'][0]['responded_24'], 2)
    eq_(r['objects'][0]['responded_72'], 2)
    eq_(r['objects'][0]['questions'], 4)
    r = self._get_api_result('api.kpi.questions', locale='en-US')
    eq_(r['objects'][0]['solved'], 1)
    eq_(r['objects'][0]['responded_24'], 2)
    eq_(r['objects'][0]['responded_72'], 2)
    eq_(r['objects'][0]['questions'], 3)
    r = self._get_api_result('api.kpi.questions', locale='pt-BR')
    eq_(r['objects'][0]['questions'], 1)
    assert ('solved' not in r['objects'][0])
    assert ('responded_24' not in r['objects'][0])
    assert ('responded_72' not in r['objects'][0])
