Skip to content
Snippets Groups Projects
Verified Commit 299922bf authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: Filling XLSX

Tests now also test for handling of invalid data.
parent 734b70b4
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!93Filling XLSX: Everything except multiple choice.
Pipeline #48265 passed
{
"Training": {
"duration": 1.0,
"participants": 0.5
},
"Person": {
"family_name": "Auric",
"given_name": "Goldfinger",
"Organisation": "Federal Reserve"
}
}
......@@ -22,6 +22,8 @@
import os
import tempfile
import jsonschema.exceptions as schema_exc
import pytest
from caosadvancedtools.table_json_conversion.fill_xlsx import (
_get_path_rows, _get_row_type_column_index, fill_template)
from openpyxl import load_workbook
......@@ -76,3 +78,17 @@ def test_fill_xlsx():
template_file=rfp("data/multiple_refs_template.xlsx"),
known_good=rfp("data/multiple_refs_data.xlsx"),
schema=rfp("data/multiple_refs_schema.json"))
def test_errors():
with pytest.raises(AssertionError) as exc:
fill_and_compare(json_file=rfp("data/error_simple_data.json"),
template_file=rfp("data/simple_template.xlsx"),
known_good=rfp("data/simple_data.xlsx"))
assert "Auric\nSteve" in str(exc.value)
with pytest.raises(schema_exc.ValidationError) as exc:
fill_and_compare(json_file=rfp("data/error_simple_data.json"),
template_file=rfp("data/simple_template.xlsx"),
known_good=rfp("data/simple_data.xlsx"),
schema=rfp("data/simple_schema.json"))
assert exc.value.message == "0.5 is not of type 'integer'"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment