예제 #1
0
def test_encode_no_input(render_image, encode, read, capsys):
    console.do_encode([])

    encode.assert_not_called()
    render_image.assert_not_called()
    read.assert_called_once_with()

    out, err = capsys.readouterr()
    assert not out
    assert "No input given" in err
예제 #2
0
def test_encode_no_input(render_image, encode, read, capsys):
    console.do_encode([])

    encode.assert_not_called()
    render_image.assert_not_called()
    read.assert_called_once_with()

    out, err = capsys.readouterr()
    assert not out
    assert "No input given" in err
예제 #3
0
def test_encode_exception(render_image, encode, capsys):
    encode.side_effect = ValueError("FAILED")

    console.do_encode(["foo"])

    encode.assert_called_once_with("foo",
                                   columns=6,
                                   encoding='utf-8',
                                   security_level=2)
    render_image.assert_not_called()

    out, err = capsys.readouterr()
    assert not out
    assert "FAILED" in err
예제 #4
0
def test_encode_exception(render_image, encode, capsys):
    encode.side_effect = ValueError("FAILED")

    console.do_encode(["foo"])

    encode.assert_called_once_with(
        "foo",
        columns=6,
        encoding='utf-8',
        security_level=2
    )
    render_image.assert_not_called()

    out, err = capsys.readouterr()
    assert not out
    assert "FAILED" in err
예제 #5
0
def test_encode(render_image, encode, capsys):
    text = "foo"

    console.do_encode([text])

    encode.assert_called_once_with(text,
                                   columns=6,
                                   encoding='utf-8',
                                   security_level=2)

    render_image.assert_called_once_with('RETVAL',
                                         bg_color='#FFFFFF',
                                         fg_color='#000000',
                                         padding=20,
                                         ratio=3,
                                         scale=3)
예제 #6
0
def test_encode(render_image, encode, capsys):
    text = "foo"

    console.do_encode([text])

    encode.assert_called_once_with(
        text,
        columns=6,
        encoding='utf-8',
        security_level=2
    )

    render_image.assert_called_once_with(
        'RETVAL',
        bg_color='#FFFFFF',
        fg_color='#000000',
        padding=20,
        ratio=3,
        scale=3
    )