Esempio n. 1
0
def test_integration_with_conventions(xpath, db4, tmpdir, args):
    DOCDIR.copy(tmpdir)
    result = tmpdir / 'result.xml'
    indexfile = tmpdir / 'index.xml'
    conventions = tmpdir / 'preface.xml'

    # Use the faked parsed cli argparser object
    args.output = str(result)
    args.indexfile = str(indexfile)
    args.conventions = str(conventions)
    args.db4 = db4
    args.params.append(('productname', args.productname))
    args.params.append(('productnumber', args.productnumber))

    process(args)

    assert result.exists()
    xml = etree.parse(str(result))
    preface_title = xml.xpath(xpath[0], namespaces=NSMAP)
    assert preface_title
    preface_para = xml.xpath(xpath[1], namespaces=NSMAP)
    assert preface_para
    book = xml.getroot()
    assert [etree.QName(i.tag).localname
            for i in book.iterchildren()] == xpath[2]
Esempio n. 2
0
def test_filenotfound1(args):
    #
    args.output = 'result.xml'
    args.indexfile = 'file-does-not-exist.xml'

    with pytest.raises((FileNotFoundError, OSError)):
        process(args)
Esempio n. 3
0
def test_integration_with_productname(tmpdir, args):
    DOCDIR.copy(tmpdir)
    result = tmpdir / 'result.xml'
    indexfile = tmpdir / 'index.xml'

    # Use the faked parsed cli argparser object
    args.output = str(result)
    args.indexfile = str(indexfile)
    args.params.append(('productname', args.productname))
    args.db4 = True
    process(args)
    assert result.exists()
    xml = etree.parse(str(result))
    assert xml.xpath('/book')
def test_multiple_output_files(tmpdir, args):
    #set the tmpdir and the indexfile
    DOCDIR = HERE / 'data/doc.002'
    DOCDIR.copy(tmpdir)
    indexfile = tmpdir / 'index.xml'
    outdir = tmpdir / "out"
    #arguments...
    args.indexfile = str(indexfile)
    args.output = str(tmpdir / "out/foo.xml")
    args.nsplit = False
    process(args)

    assert outdir.exists()
    assert len(outdir.listdir()) == 2
def test_single_output_file(tmpdir, args):
    #set the tmpdir and the indexfile
    DOCDIR = HERE / 'data/doc.002'
    DOCDIR.copy(tmpdir)
    indexfile = tmpdir / 'index.xml'
    #arguments...
    args.output = str(tmpdir / "out/foo.xml")
    args.indexfile = str(indexfile)
    args.nsplit = True
    process(args)

    assert local(args.output).exists()
    tree = etree.parse(args.output)
    assert tree.xpath('/d:book', namespaces=NSMAP)
Esempio n. 6
0
def test_integration(xpath, db4, tmpdir, args):
    DOCDIR.copy(tmpdir)
    result = tmpdir / 'result.xml'
    indexfile = tmpdir / 'index.xml'

    # Use the faked parsed cli argparser object
    args.output = str(result)
    args.indexfile = str(indexfile)
    args.params.append(('productname', args.productname))
    args.params.append(('productnumber', args.productnumber))
    args.db4 = db4

    process(args)

    assert result.exists()
    xml = etree.parse(str(result))
    assert_xpaths(xml, xpath, args)
Esempio n. 7
0
def test_integration_with_stdout(xpath, db4, tmpdir, capsys, args):
    DOCDIR.copy(tmpdir)
    # result = str(tmpdir / 'result.xml')
    indexfile = tmpdir / 'index.xml'

    args.output = None
    args.db4 = db4
    args.indexfile = str(indexfile)
    args.params.append(('productname', args.productname))
    args.params.append(('productnumber', args.productnumber))
    process(args)
    out, err = capsys.readouterr()
    assert out
    assert not err
    # with open(result, 'w') as fh:
    #    fh.write(out)
    xml = etree.fromstring(out)
    assert_xpaths(xml, xpath, args)
Esempio n. 8
0
def test_integration_figure(xpath, db4, tmpdir, args):
    DOCDIR.copy(tmpdir)
    result = tmpdir / 'result.xml'
    indexfile = tmpdir / 'index.xml'

    # Use the faked parsed cli argparser object
    args.output = str(result)
    args.indexfile = str(indexfile)
    args.db4 = db4

    process(args)

    assert result.exists()
    xml = etree.parse(str(result))

    figure = xml.find(xpath[0], namespaces=NSMAP)
    assert figure is not None
    title = figure.find(xpath[1], namespaces=NSMAP)
    assert title is not None
    assert title.text == 'Foo Image'
Esempio n. 9
0
def test_integration_with_legalnotice(xpath, db4, tmpdir, args):
    DOCDIR.copy(tmpdir)
    result = tmpdir / 'result.xml'
    indexfile = tmpdir / 'index.xml'
    legalfile = tmpdir / 'legal.xml'

    # Use the faked parsed cli argparser object
    args.output = str(result)
    args.indexfile = str(indexfile)
    args.legalnotice = str(legalfile)
    args.db4 = db4

    process(args)
    assert result.exists()
    xml = etree.parse(str(result))
    legalnotice = xml.xpath(xpath[0], namespaces=NSMAP)
    assert legalnotice
    title = xml.xpath(xpath[1], namespaces=NSMAP)
    assert title
    assert title[0].text == 'Legal Notice'