예제 #1
0
def test_filenotfound1(args):
    #
    args.output = 'result.xml'
    args.indexfile = 'file-does-not-exist.xml'

    with pytest.raises((FileNotFoundError, OSError)):
        process(args)
예제 #2
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')
예제 #3
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)
예제 #4
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)
예제 #5
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'
예제 #6
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'
예제 #7
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]