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

WIP: XLSX converter errors.

parent 0519fc38
No related branches found
No related tags found
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!120XLSX-Konverter: Bessere Fehlermeldung bei inkorrektem Typ in Spalte, zusätzlicher Spalte
Pipeline #57633 failed
...@@ -54,9 +54,9 @@ def _column_id_to_chars(num): ...@@ -54,9 +54,9 @@ def _column_id_to_chars(num):
return _column_id_to_chars(int(num / 26) - 1) + chr(int(num % 26) + 65) return _column_id_to_chars(int(num / 26) - 1) + chr(int(num % 26) + 65)
def _format_exception_table(exceptions: list(tuple), worksheet_title: str, def _format_exception_table(exceptions: list[tuple], worksheet_title: str,
column_names: Optional[dict, list] = None, column_names: Optional[Union[dict, list]] = None,
max_line_length: Optional[int] = 120) -> str: max_line_length: int = 120) -> str:
""" """
Given a list of tuples containing a row and column number as well as an Given a list of tuples containing a row and column number as well as an
exception in that order, and the title of the current worksheet, returns exception in that order, and the title of the current worksheet, returns
...@@ -77,7 +77,7 @@ def _format_exception_table(exceptions: list(tuple), worksheet_title: str, ...@@ -77,7 +77,7 @@ def _format_exception_table(exceptions: list(tuple), worksheet_title: str,
column_names[column_num] should return the name of column_names[column_num] should return the name of
column column_names. column column_names.
If given, exceptions will be clustered by column. If given, exceptions will be clustered by column.
max_line_length: int max_line_length: int, default=120
Soft cap for the line length of the resulting table Soft cap for the line length of the resulting table
Return Return
...@@ -382,7 +382,7 @@ class XLSXConverter: ...@@ -382,7 +382,7 @@ class XLSXConverter:
raise raise
self._errors[(sheet.title, row_idx)] = kerr.definitions self._errors[(sheet.title, row_idx)] = kerr.definitions
if exceptions != []: if exceptions:
exception_table = _format_exception_table(exceptions, sheet.title, exception_table = _format_exception_table(exceptions, sheet.title,
col_names) col_names)
raise jsonschema.ValidationError(exception_table) raise jsonschema.ValidationError(exception_table)
......
No preview for this file type
...@@ -126,11 +126,14 @@ def test_wrong_datatype(): ...@@ -126,11 +126,14 @@ def test_wrong_datatype():
assert "J7" in line assert "J7" in line
if "1.5 is not of type 'integer'" in line: if "1.5 is not of type 'integer'" in line:
assert "K7" in line assert "K7" in line
if "1.2345 is not of type 'integer'" in line:
assert "K8" in line
# No additional type errors # No additional type errors
if "is not of type 'boolean'" in str(caught.value): # ToDo: Remove when boolean is fixed if "is not of type 'boolean'" in str(caught.value): # ToDo: Remove when boolean is fixed
assert str(caught.value).count("is not of type") == 3 assert str(caught.value).count("is not of type") == 3
else: else:
assert str(caught.value).count("is not of type") == 2 assert str(caught.value).count("is not of type") == 2 # FIXME when everything works as
# # expected, set correct number.
def test_additional_column(): def test_additional_column():
......
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