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')
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')
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'))
def test_no_filename(): with pytest.raises(Exception): generate_form(None, None)
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')
def test_file_exists(): with pytest.raises(Exception): generate_form('test', None)