def test_dict_grouper_overwriting_input(self):
        processor = util_processors.DictGrouper(key_path='key', input_path='input', fallback='fallback')

        group_a = [dict(key='a', n=1), dict(key='a', n=3)]
        group_b = [dict(key='b', n=2), dict(key='b', n=4)]
        # Interleave the dicts, so the processor does not rely on the list being sorted.
        baton = dict(input=util.interleaved(group_a, group_b))

        processor.process(baton)

        # The result should be grouped
        self.assertEquals(baton, dict(input=dict(a=group_a, b=group_b)))
    def test_dict_grouper_groups_reversed_iterable_of_dicts(self):
        processor = util_processors.DictGrouper(key_path='key', input_path='list_of_dicts', output_path='grouped', fallback='fallback')

        group_a = [dict(key='a', n=3), dict(key='a', n=1)]
        group_b = [dict(key='b', n=4), dict(key='b', n=2)]
        # Interleave the dicts, so the processor does not rely on the list being sorted.
        baton = dict(list_of_dicts=util.interleaved(group_a, group_b))

        # Copy it, so we can assert it's not modified
        original_input = copy.deepcopy(baton['list_of_dicts'])
        processor.process(baton)

        # The result should be grouped
        self.assertEquals(baton['grouped'], dict(a=group_a, b=group_b))
        # The input should be untouched
        self.assertEquals(baton['list_of_dicts'], original_input)