Exemplo n.º 1
0
def test_item_untouched(testapp):
    """Metadata processor has to ignore items if no metadata are passed."""

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

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

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

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item(
            {"content": "the Force", "author": "yoda", "type": "memoire"}
        )
    ]
Exemplo n.º 3
0
def test_args_overwrite(testapp, overwrite, author):
    """Metadata processor has to respect 'overwrite' argument."""

    stream = metadata.process(
        testapp,
        [holocron.Item({"content": "the Force", "author": "skywalker"})],
        metadata={"author": "yoda", "type": "memoire"},
        overwrite=overwrite,
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item(
            {"content": "the Force", "author": author, "type": "memoire"}
        )
    ]
Exemplo n.º 4
0
def test_item_many(testapp, amount):
    """Metadata processor has to work with stream."""

    stream = metadata.process(
        testapp,
        [
            holocron.Item({"content": "the key is #%d" % i, "author": "luke"})
            for i in range(amount)
        ],
        metadata={"author": "yoda", "type": "memoire"},
    )

    assert isinstance(stream, collections.abc.Iterable)
    assert list(stream) == [
        holocron.Item(
            {
                "content": "the key is #%d" % i,
                "author": "yoda",
                "type": "memoire",
            }
        )
        for i in range(amount)
    ]
Exemplo n.º 5
0
def test_args_bad_value(testapp, args, error):
    """Metadata processor has to validate input arguments."""

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