@defer.inlineCallbacks
    def test_MapReduce(self):
        yield self.coll.insert([
            {"kid": "John", "grade": 5},
            {"kid": "Kate", "grade": 4},
            {"kid": "John", "grade": 4},
            {"kid": "Kate", "grade": 4},
            {"kid": "Adam", "grade": 4},
            {"kid": "Kate", "grade": 2},
            {"kid": "John", "grade": 5},
        ])

        t_map = """
            function () {
                emit(this.kid, this.grade);
            }
        """

        t_reduce = """
            function (key, values) {
                return Array.sum(values);
            }
        """

        result = yield self.coll.map_reduce(t_map, t_reduce, out={"inline": 1})
        self.assertEqual(len(result), 3)
        self.assertTrue({"_id": "John", "value": 14} in result)
        self.assertTrue({"_id": "Kate", "value": 10} in result)
        self.assertTrue({"_id": "Adam", "value": 4} in result)

        result = yield self.coll.map_reduce(t_map, t_reduce, out={"inline": 1}, full_response=True)
        self.assertTrue(result["ok"], 1)
        self.assertTrue("counts" in result)
        self.assertTrue("results" in result)
dataset/ETHPy150Open twisted/txmongo/tests/test_queries.py/TestMapReduce.test_MapReduce/original