Example #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/
""")
Example #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: ')
Example #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)
Example #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')
Example #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')
Example #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
Example #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
Example #8
0
def test_help_by_default(capsys):
    with pytest.raises(SystemExit):
        run()
    out, err = capsys.readouterr()
    assert out.startswith('usage: ')
Example #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: ')
Example #10
0
def test_version(capsys):
    with pytest.raises(SystemExit):
        run('-V')
    out, err = capsys.readouterr()
    assert match(r'^wdmapper \d+\.\d+\.\d+', out)
Example #11
0
def test_property_not_found(capsys):
    with pytest.raises(SystemExit):
        run('Ä')
    out, err = capsys.readouterr()
    assert match('^property not found: Ä', err)