Ejemplo n.º 1
0
def test_simple(tmpdir, monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['treepoem', '-o',
         str(tmpdir.join('test.png')), 'barcodedata'])
    main()
    assert tmpdir.join('test.png').check(exists=True)
Ejemplo n.º 2
0
def test_simple(tmpdir, monkeypatch):
    monkeypatch.setattr(
        sys, "argv",
        ["treepoem", "-o",
         str(tmpdir.join("test.png")), "barcodedata"])
    main()
    assert tmpdir.join("test.png").check(exists=True)
Ejemplo n.º 3
0
def test_help(monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '--help'])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 0
    out, err = capsys.readouterr()
    assert 'Supported barcode types are: auspost,' in out
    assert err == ''
Ejemplo n.º 4
0
def test_help(monkeypatch, capsys):
    monkeypatch.setattr(sys, "argv", ["treepoem", "--help"])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 0
    out, err = capsys.readouterr()
    assert "Supported barcode types are: auspost," in out
    assert err == ""
Ejemplo n.º 5
0
def test_help(monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '--help'])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 0
    out, err = capsys.readouterr()
    assert 'Supported barcode types are: auspost,' in out
    assert err == ''
Ejemplo n.º 6
0
def test_unsupported_file_format(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '-f', 'invalid-image-format',
                                      '-o', str(tmpdir.join('test.bin')), 'barcodedata'])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join('test.bin').check(exists=False)
    out, err = capsys.readouterr()
    assert out == ''
    assert 'Image format "invalid-image-format" is not supported' in err
Ejemplo n.º 7
0
def test_unsupported_barcode_type(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '-t', 'invalid-barcode-type',
                                      '-o', str(tmpdir.join('test.png')), 'barcodedata'])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join('test.png').check(exists=False)
    out, err = capsys.readouterr()
    assert out == ''
    assert 'Barcode type "invalid-barcode-type" is not supported. Supported barcode types are:' in err
Ejemplo n.º 8
0
def test_unsupported_file_format(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', [
        'treepoem', '-f', 'invalid-image-format', '-o',
        str(tmpdir.join('test.bin')), 'barcodedata'
    ])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join('test.bin').check(exists=False)
    out, err = capsys.readouterr()
    assert out == ''
    assert 'Image format "invalid-image-format" is not supported' in err
Ejemplo n.º 9
0
def test_unsupported_barcode_type(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', [
        'treepoem', '-t', 'invalid-barcode-type', '-o',
        str(tmpdir.join('test.png')), 'barcodedata'
    ])
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join('test.png').check(exists=False)
    out, err = capsys.readouterr()
    assert out == ''
    assert 'Barcode type "invalid-barcode-type" is not supported. Supported barcode types are:' in err
Ejemplo n.º 10
0
def test_stdout(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', 'barcodedata'])
    main()
    out, err = capsys.readouterr()
    print(out)
    print(err)
    out_lines = out.splitlines()
    assert out_lines[:3] == [
        # xbm format
        '#define im_width 86',
        '#define im_height 86',
        'static char im_bits[] = {',
    ]
    assert err == ''
Ejemplo n.º 11
0
def test_stdout(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, "argv", ["treepoem", "barcodedata"])
    main()
    out, err = capsys.readouterr()
    print(out)
    print(err)
    out_lines = out.splitlines()
    assert out_lines[:3] == [
        # xbm format
        "#define im_width 86",
        "#define im_height 86",
        "static char im_bits[] = {",
    ]
    assert err == ""
Ejemplo n.º 12
0
def test_stdout(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(sys, 'argv', ['treepoem', 'barcodedata'])
    main()
    out, err = capsys.readouterr()
    print(out)
    print(err)
    out_lines = out.splitlines()
    assert out_lines[:3] == [
        # xbm format
        '#define im_width 86',
        '#define im_height 86',
        'static char im_bits[] = {',
    ]
    assert err == ''
Ejemplo n.º 13
0
def test_unsupported_file_format(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(
        sys,
        "argv",
        [
            "treepoem",
            "-f",
            "invalid-image-format",
            "-o",
            str(tmpdir.join("test.bin")),
            "barcodedata",
        ],
    )
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join("test.bin").check(exists=False)
    out, err = capsys.readouterr()
    assert out == ""
    assert 'Image format "invalid-image-format" is not supported' in err
Ejemplo n.º 14
0
def test_unsupported_barcode_type(tmpdir, monkeypatch, capsys):
    monkeypatch.setattr(
        sys,
        "argv",
        [
            "treepoem",
            "-t",
            "invalid-barcode-type",
            "-o",
            str(tmpdir.join("test.png")),
            "barcodedata",
        ],
    )
    with pytest.raises(SystemExit) as excinfo:
        main()
    assert excinfo.value.code == 2
    assert tmpdir.join("test.png").check(exists=False)
    out, err = capsys.readouterr()
    assert out == ""
    assert (
        'Barcode type "invalid-barcode-type" is not supported. Supported ' +
        "barcode types are:") in err
Ejemplo n.º 15
0
def test_stdout_with_format(tmpdir, monkeypatch, capfdbinary):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '-f', 'png', 'barcodedata'])
    main()
    out, err = capfdbinary.readouterr()
    assert out.startswith(b'\x89PNG')  # PNG magic bytes
    assert err == b''
Ejemplo n.º 16
0
def test_stdout_with_format(tmpdir, monkeypatch, capfdbinary):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '-f', 'png', 'barcodedata'])
    main()
    out, err = capfdbinary.readouterr()
    assert out.startswith(b'\x89PNG')  # PNG magic bytes
    assert err == b''
Ejemplo n.º 17
0
def test_stdout_with_format(tmpdir, monkeypatch, capfdbinary):
    monkeypatch.setattr(sys, "argv", ["treepoem", "-f", "png", "barcodedata"])
    main()
    out, err = capfdbinary.readouterr()
    assert out.startswith(b"\x89PNG")  # PNG magic bytes
    assert err == b""
Ejemplo n.º 18
0
def test_simple(tmpdir, monkeypatch):
    monkeypatch.setattr(sys, 'argv', ['treepoem', '-o', str(tmpdir.join('test.png')), 'barcodedata'])
    main()
    assert tmpdir.join('test.png').check(exists=True)