Пример #1
0
    def test_filter(self):
        """DataFlow filtering should behave as the filter base function
        """

        left = dataflow.DataFlow(body=['left'])
        right = dataflow.DataFlow(body=['right'])

        assert (left + right).filter(lambda x: x == 'right').body == filter(
            lambda x: x == 'right', (left + right).body)
Пример #2
0
    def test_add(self):
        """DataFlow summation should result in a new DataFlow
        with concatenated body
        """

        left = dataflow.DataFlow(body=['left'])
        right = dataflow.DataFlow(body=['right'])

        assert (left + right).body == ['left', 'right']
Пример #3
0
    def test_sortby(self):
        """DataFlow sorting should behave as the sorted base function
        """

        flow = dataflow.DataFlow(body=[2, 3, 1])
        assert flow.sortby(lambda x: x).body == sorted(flow.body,
                                                       key=lambda x: x)
Пример #4
0
    def test_reduce(self):
        """DataFlow reducing should behave as the reduce base function
        """

        flow = dataflow.DataFlow(body=['a', 'b', 'c'])
        assert flow.reduce(lambda a, b: a + b,
                           '') == reduce(lambda a, b: a + b, flow.body)
Пример #5
0
    def test_init(self):
        """DataFlow body should be a copy of input list at init
        """

        flow = dataflow.DataFlow(body=['a', 'b', 'c'])
        assert flow.list() == ['a', 'b', 'c']
Пример #6
0
    def test_dataflow(self):
        """DataFlow object should have a body attribute
        """

        flow = dataflow.DataFlow(body=['a', 'b', 'c'])
        assert hasattr(flow, 'body')