Beispiel #1
0
    def test_map4(self):

        row = {'field1': 'a', 'field2': 'b', 'field3': None, sv.VARS.ID: 1}
        result = self.agg.map(row)

        goal = ca.CompoundResult(
            set(),  # top-level
            [
                ca.CompoundResult(set([1]), [set([1]), set([1])]),
                # disjunctive result
                set()
            ])  # agg3
        self.assertEqual(result, goal)
Beispiel #2
0
    def test_map3(self):

        row = {'field1': 'c', 'field2': 'c', sv.VARS.ID: 1}
        result = self.agg.map(row)

        goal_toplevel = set()
        goal_subs = [set(), set()]
        goal = ca.CompoundResult(goal_toplevel, goal_subs)
        self.assertEqual(result, goal)
Beispiel #3
0
    def test_reduce2(self):

        row1 = {'field1': 'a', 'field2': None, 'field3': 'c', sv.VARS.ID: 1}
        result1 = self.agg.map(row1)

        row2 = {'field1': None, 'field2': 'b', 'field3': 'c', sv.VARS.ID: 2}
        result2 = self.agg.map(row2)

        row3 = {'field1': None, 'field2': None, 'field3': None, sv.VARS.ID: 3}
        result3 = self.agg.map(row3)

        result = self.agg.reduce(result1, self.agg.reduce(result2, result3))

        goal = ca.CompoundResult(
            set([1, 2]),  # top-level
            [
                ca.CompoundResult(set([1, 2]), [set([1]), set([2])]),
                # disjunctive result
                set([1, 2])
            ])  # agg3
        self.assertEqual(result, goal)
Beispiel #4
0
    def test_reduce2(self):

        row1 = {'field1': 'a', 'field2': 'b', sv.VARS.ID: 1}
        result1 = self.agg.map(row1)

        row2 = {'field1': 'a', 'field2': None, sv.VARS.ID: 2}
        result2 = self.agg.map(row2)

        row3 = {'field1': None, 'field2': 'b', sv.VARS.ID: 3}
        result3 = self.agg.map(row3)

        result = self.agg.reduce(result1, self.agg.reduce(result2, result3))

        goal_toplevel = set([1])
        goal_subs = [set([1, 2]), set([1, 3])]
        goal = ca.CompoundResult(goal_toplevel, goal_subs)
        self.assertEqual(result, goal)