def testShouldReturnArgumentWhenNothingToCompose(self): expected = 1 composed = compose() actual = composed(expected) self.assertEqual(actual, expected)
def wrap(reducer, initial_state): store = other(reducer, initial_state) dispatch = store.dispatch api = {"dispatch": lambda action: dispatch(action), "get_state": store.get_state} chain = map(lambda middleware: middleware(api), middlewares) dispatch = compose(*chain)(store.dispatch) store.dispatch = dispatch return store
def testShouldComposeFunctions(self): value = 1 def func1(param): self.assertEqual(param, value) return param def func2(param): self.assertEqual(param, value) return param composed = compose(func1, func2) self.assertTrue(callable(composed)) composed(value)