# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import epubcheck
from epubcheck import samples
from epubcheck.cli import main


def test_valid():
    assert epubcheck.validate(samples.EPUB3_VALID)


def test_invalid():
    assert not epubcheck.validate(samples.EPUB3_INVALID)


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


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

@@ -57,16 +57,57 @@
 iterals%0A
+import sys%0A%0Aimport pytest%0Aimport tablib%0A%0A
 import e
@@ -734,8 +734,667 @@
 de == 1%0A
+%0A%0Adef test_csv_report(tmp_path):%0A    results_file = tmp_path / 'results.csv'%0A    main(%5Bsamples.EPUB3_INVALID, '--csv', str(results_file)%5D)%0A%0A    with results_file.open('r') as f:%0A        dataset = tablib.Dataset().load(f.read(), format='csv', delimiter=';')%0A        assert dataset%5B0%5D%5B:3%5D == ('OPF-003', 'WARNING', 'invalid.epub')%0A%0A%0Adef test_xls_report(tmp_path):%0A    results_file = tmp_path / 'results.xls'%0A    main(%5Bsamples.EPUB3_INVALID, '--xls', str(results_file)%5D)%0A%0A    with results_file.open('rb') as f:%0A        databook = tablib.Databook().load(f.read(), format='xls')%0A        assert databook.sheets()%5B1%5D%5B0%5D%5B:3%5D == ('OPF-003', 'WARNING', 'invalid.epub')%0A

Add tests for CSV and XLS reporting