Exemplo n.º 1
0
def test_item_processor_with_args(testapp):
    """Pipe processor has to pass down processors arguments."""

    stream = pipe.process(
        testapp,
        [holocron.Item({
            "content": "the Force",
            "author": "skywalker"
        })],
        pipe=[{
            "name": "spam",
            "args": {
                "text": 1
            }
        }],
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item({
            "content": "the Force",
            "author": "skywalker",
            "spam": 1
        })
    ]
Exemplo n.º 2
0
def test_item(testapp):
    """Pipe processor has to work!"""

    stream = pipe.process(
        testapp,
        [holocron.Item({
            "content": "the Force",
            "author": "skywalker"
        })],
        pipe=[{
            "name": "spam"
        }, {
            "name": "eggs"
        }, {
            "name": "rice"
        }],
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item({
            "content": "the Force #friedeggs",
            "author": "skywalker",
            "spam": 42,
        }),
        holocron.Item({"content": "rice"}),
    ]
Exemplo n.º 3
0
def test_item_many(testapp, amount):
    """Pipe processor has to work with stream."""

    stream = pipe.process(
        testapp,
        [
            holocron.Item({
                "content": "the Force (%d)" % i,
                "author": "skywalker"
            }) for i in range(amount)
        ],
        pipe=[{
            "name": "spam"
        }, {
            "name": "eggs"
        }],
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item({
            "content": "the Force (%d) #friedeggs" % i,
            "author": "skywalker",
            "spam": 42,
        }) for i in range(amount)
    ]
Exemplo n.º 4
0
def test_args_pipeline_empty(testapp):
    """Pipe processor with empty pipeline has to pass by."""

    stream = pipe.process(
        testapp,
        [holocron.Item({
            "content": "the Force",
            "author": "skywalker"
        })],
        pipe=[],
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item({
            "content": "the Force",
            "author": "skywalker"
        })
    ]
Exemplo n.º 5
0
def test_args_bad_value(testapp, args, error):
    """Pipe processor has to validate input arguments."""

    with pytest.raises(ValueError) as excinfo:
        next(pipe.process(testapp, [], **args))
    assert str(excinfo.value) == error