Exemplo n.º 1
0
def test_csv_report(tmp_path):
    results_file = tmp_path / 'results.csv'
    main([samples.EPUB3_INVALID, '--csv', str(results_file)])

    with results_file.open('r') as f:
        dataset = tablib.Dataset().load(f.read(), format='csv', delimiter=';')
        assert dataset[0][:3] == ('OPF-003', 'WARNING', 'invalid.epub')
Exemplo n.º 2
0
def test_xls_report(tmp_path):
    results_file = tmp_path / 'results.xls'
    main([samples.EPUB3_INVALID, '--xls', str(results_file)])

    with results_file.open('rb') as f:
        databook = tablib.Databook().load(f.read(), format='xls')
        assert databook.sheets()[1][0][:3] == ('OPF-003', 'WARNING',
                                               'invalid.epub')
Exemplo n.º 3
0
def test_main():
    assert main([]) == 0
Exemplo n.º 4
0
"""
Entrypoint module, in case you use `python -mepubcheck`.


Why does this file exist, and why __main__? For more info, read:

- https://www.python.org/dev/peps/pep-0338/
- https://docs.python.org/2/using/cmdline.html#cmdoption-m
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
"""
import sys

from epubcheck.cli import main

if __name__ == "__main__":
    sys.exit(main())
Exemplo n.º 5
0
def test_main_invalid(capsys):
    argv = [samples.EPUB3_INVALID]
    exit_code = main(argv)
    out, err = capsys.readouterr()
    assert 'ERROR' in err and 'WARNING' in out
    assert exit_code == 1
Exemplo n.º 6
0
def test_main_valid(capsys):
    argv = [samples.EPUB3_VALID]
    exit_code = main(argv)
    out, err = capsys.readouterr()
    assert 'ERROR' not in out and 'ERROR' not in err
    assert exit_code == 0
Exemplo n.º 7
0
def test_main_invalid(capsys):
    argv = [samples.EPUB3_INVALID]
    exit_code = main(argv)
    out, err = capsys.readouterr()
    assert 'ERROR' in err and 'WARNING' in out
    assert exit_code == 1
Exemplo n.º 8
0
def test_main_valid(capsys):
    argv = [samples.EPUB3_VALID]
    exit_code = main(argv)
    out, err = capsys.readouterr()
    assert 'ERROR' not in out and 'ERROR' not in err
    assert exit_code == 0