def test_kb_vote(self):
        r1 = RevisionFactory(document__locale='en-US')
        r2 = RevisionFactory(document__locale='es')
        r3 = RevisionFactory(document__locale='es')
        for r in [r1, r2, r3]:
            HelpfulVoteFactory(revision=r)
            HelpfulVoteFactory(revision=r)
            HelpfulVoteFactory(revision=r, helpful=True)

        # Assign 2 documents to Firefox OS and 1 to Firefox
        firefox_os = ProductFactory(slug='firefox-os')
        firefox = ProductFactory(slug='firefox')
        r1.document.products.add(firefox_os)
        r2.document.products.add(firefox_os)
        r3.document.products.add(firefox)

        # All votes should be counted if we don't specify a locale
        r = self._get_api_result('api.kpi.kb-votes')
        eq_(r['objects'][0]['kb_helpful'], 3)
        eq_(r['objects'][0]['kb_votes'], 9)

        # Only en-US votes:
        r = self._get_api_result('api.kpi.kb-votes', locale='en-US')
        eq_(r['objects'][0]['kb_helpful'], 1)
        eq_(r['objects'][0]['kb_votes'], 3)

        # Only es votes:
        r = self._get_api_result('api.kpi.kb-votes', locale='es')
        eq_(r['objects'][0]['kb_helpful'], 2)
        eq_(r['objects'][0]['kb_votes'], 6)

        # Only Firefox OS votes:
        r = self._get_api_result('api.kpi.kb-votes', product='firefox-os')
        eq_(r['objects'][0]['kb_helpful'], 2)
        eq_(r['objects'][0]['kb_votes'], 6)

        # Only Firefox votes:
        r = self._get_api_result('api.kpi.kb-votes', product='firefox')
        eq_(r['objects'][0]['kb_helpful'], 1)
        eq_(r['objects'][0]['kb_votes'], 3)

        # Only Firefox OS + es votes:
        r = self._get_api_result(
            'api.kpi.kb-votes', product='firefox-os', locale='es')
        eq_(r['objects'][0]['kb_helpful'], 1)
        eq_(r['objects'][0]['kb_votes'], 3)
Test vote API call.
dataset/ETHPy150Open mozilla/kitsune/kitsune/kpi/tests/test_api.py/KpiApiTests.test_kb_vote