From da4ba2603c25e4e658e3ba2026c71df85f176e27 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Mon, 1 May 2017 18:50:06 +0200 Subject: [PATCH] Update basic tests. --- tests/test_basics.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test_basics.py b/tests/test_basics.py index 4243cf2..7a9f317 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -3,6 +3,7 @@ from unittest.mock import MagicMock import bonobo import pytest from bonobo.config.processors import ContextCurrifier +from bonobo.constants import NOT_MODIFIED def test_count(): @@ -24,3 +25,38 @@ def test_count(): assert 0 == len(bag.kwargs) assert 1 == len(bag.args) assert bag.args[0] == 42 + + +def test_identity(): + assert bonobo.identity(42) == 42 + + +def test_limit(): + limit = bonobo.Limit(2) + results = [] + for i in range(42): + results += list(limit()) + assert results == [NOT_MODIFIED] * 2 + + +def test_limit_not_there(): + limit = bonobo.Limit(42) + results = [] + for i in range(10): + results += list(limit()) + assert results == [NOT_MODIFIED] * 10 + + +def test_tee(): + inner = MagicMock(side_effect=bonobo.identity) + tee = bonobo.Tee(inner) + results = [] + for i in range(10): + results.append(tee('foo')) + + assert results == [NOT_MODIFIED] * 10 + assert len(inner.mock_calls) == 10 + + +def test_noop(): + assert bonobo.noop(1, 2, 3, 4, foo='bar') == NOT_MODIFIED