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/ """)
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: ')
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)
def test_csv_to_jskos(capsys): run('convert', '-i', 'tests/simple.csv', '-t', 'jskos') out, err = capsys.readouterr() assert out == slurp('tests/simple.ndjson')
def test_csv_to_beacon(capsys): run('convert', '-i', 'tests/simple.csv', '-t', 'beacon') out, err = capsys.readouterr() assert out == slurp('tests/simple.txt')
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
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
def test_help_by_default(capsys): with pytest.raises(SystemExit): run() out, err = capsys.readouterr() assert out.startswith('usage: ')
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: ')
def test_version(capsys): with pytest.raises(SystemExit): run('-V') out, err = capsys.readouterr() assert match(r'^wdmapper \d+\.\d+\.\d+', out)
def test_property_not_found(capsys): with pytest.raises(SystemExit): run('Ä') out, err = capsys.readouterr() assert match('^property not found: Ä', err)