Esempio n. 1
0
def test_property(capsys):
    run('P214')
    out, err = capsys.readouterr()
    assert out.startswith("""\
#FORMAT: BEACON
#NAME: VIAF ID
#DESCRIPTION: Mapping from Wikidata IDs to VIAF IDs
#PREFIX: http://www.wikidata.org/entity/
#TARGET: http://viaf.org/viaf/
""")
Esempio n. 2
0
def test_unknown_format(capsys):
    with pytest.raises(SystemExit):
        run('-f', 'xxx')
    out, err = capsys.readouterr()
    assert err.startswith('input format must be one of: ')

    with pytest.raises(SystemExit):
        run('-t', 'xxx')
    out, err = capsys.readouterr()
    assert err.startswith('output format must be one of: ')
Esempio n. 3
0
def test_write_formats(tmpdir):
    formats = ['txt', 'ndjson']
    for ext in formats:
        outfile = str(tmpdir.join('tmp.' + ext))
        run('convert', '-i', 'tests/simple.csv', '-o', outfile)
        assert slurp(outfile) == slurp('tests/simple.' + ext)
Esempio n. 4
0
def test_csv_to_jskos(capsys):
    run('convert', '-i', 'tests/simple.csv', '-t', 'jskos')
    out, err = capsys.readouterr()
    assert out == slurp('tests/simple.ndjson')
Esempio n. 5
0
def test_csv_to_beacon(capsys):
    run('convert', '-i', 'tests/simple.csv', '-t', 'beacon')
    out, err = capsys.readouterr()
    assert out == slurp('tests/simple.txt')
Esempio n. 6
0
def test_read_csv_file(capsys):
    run('convert', '-i', 'tests/simple.csv', '-t', 'csv')
    out, err = capsys.readouterr()
    expect = "source, target, annotation\nxyz, 123, ☃\n"
    assert out == expect
Esempio n. 7
0
def test_read_csv_stdin(stdin, capsys):
    with stdin("föö,bar\n"):
        run('convert', '-H', '-t', 'csv')
    out, err = capsys.readouterr()
    expect = "föö, bar\n"
    assert out == expect
Esempio n. 8
0
def test_help_by_default(capsys):
    with pytest.raises(SystemExit):
        run()
    out, err = capsys.readouterr()
    assert out.startswith('usage: ')
Esempio n. 9
0
def test_unknown_command(capsys):
    with pytest.raises(SystemExit):
        run('x', 'P1', 'P2')
    out, err = capsys.readouterr()
    assert err.startswith('command must be one of: ')
Esempio n. 10
0
def test_version(capsys):
    with pytest.raises(SystemExit):
        run('-V')
    out, err = capsys.readouterr()
    assert match(r'^wdmapper \d+\.\d+\.\d+', out)
Esempio n. 11
0
def test_property_not_found(capsys):
    with pytest.raises(SystemExit):
        run('Ä')
    out, err = capsys.readouterr()
    assert match('^property not found: Ä', err)