Exemplo n.º 1
0
def test_empty_shape():
    with open('inputs/empty_shape.ttl') as f:
        generate_form(f,
                      form_destination='result.html',
                      map_destination='result.ttl')
    assert os.path.exists('result.html')
    assert filecmp.cmp('result.html', 'expected_results/empty_shape.html')
Exemplo n.º 2
0
def test_shape():
    # Contents of result can't be verified due to RDF and therefore the HTML result being unordered
    if os.path.exists('results'):
        shutil.rmtree('results')
    with open('inputs/test_shape.ttl') as f:
        generate_form(f,
                      form_destination='result.html',
                      map_destination='result.ttl')
    assert os.path.exists('result.html')
Exemplo n.º 3
0
def gen_form():
    form_filepath = config.TEMPLATES_DIR + '/form_contents.html'
    map_filepath = 'map.ttl'
    try:
        with open(config.SHAPES_FILE_PATH) as shape:
            generate_form(shape,
                          form_destination=form_filepath,
                          map_destination=map_filepath)
    except FileNotFoundError:
        return Response('No SHACL shapes file provided at ' +
                        config.SHAPES_FILE_PATH,
                        status=500,
                        mimetype='text/plain')
    return redirect(url_for('controller.form'))
Exemplo n.º 4
0
def test_no_filename():
    with pytest.raises(Exception):
        generate_form(None, None)
Exemplo n.º 5
0
def test_empty_file():
    with pytest.raises(Exception):
        with open('inputs/empty_file.ttl') as f:
            generate_form(f,
                          form_destination='result.html',
                          map_destination='result.ttl')
Exemplo n.º 6
0
def test_file_exists():
    with pytest.raises(Exception):
        generate_form('test', None)