Skip to content

Commit

Permalink
Add summary to schema, use and test schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ximenesuk committed Mar 7, 2024
1 parent 9bca267 commit e14f714
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def check_ags(filename: Path, standard_AGS4_dictionary: Optional[str] = None) ->
errors = {'File read error': [{'line': line_no, 'group': '', 'desc': description}]}
dictionary = ''

# Discard unecessary summary from errors dictionary
errors.pop('Summary of data', None)
# Use summary from errors dictionary is available
summary = errors.pop('Summary of data', [])

return dict(checker=f'python_ags4 v{python_ags4.__version__}',
errors=errors, dictionary=dictionary)
errors=errors, dictionary=dictionary, summary=summary)


def check_bgs(filename: Path, **kwargs) -> dict:
Expand Down
1 change: 1 addition & 0 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Validation(BaseModel):
message: str = Field(None, example="7 error(s) found in file!")
errors: Dict[str, List[LineError]] = Field(..., example="Rule 1a")
valid: bool = Field(..., example='false')
summary: List[dict] = list()
additional_metadata: dict = Field(...)
geojson: dict = dict()
geojson_error: str = None
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'message': 'All checks passed!',
'errors': {},
'valid': True,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand Down Expand Up @@ -97,6 +98,7 @@
],
},
"valid": False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -123,6 +125,7 @@
'AGS Format Rule 15': [{'line': '-', 'group': 'UNIT', 'desc': 'UNIT group not found.'}],
'AGS Format Rule 17': [{'line': '-', 'group': 'TYPE', 'desc': 'TYPE group not found.'}]},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand Down Expand Up @@ -287,6 +290,7 @@
"If not 'utf-8', then the encoding is most likely to be 'windows-1252' "
"aka 'cp1252')"}]},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -305,6 +309,7 @@
'group': '',
'line': 1}]},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand Down Expand Up @@ -705,6 +710,7 @@
'It is highly recommended that the file be saved without BOM encoding '
'to avoid issues with other software.'}]},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -724,6 +730,7 @@
'line': 1}]},

'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -738,6 +745,7 @@
'errors': {'File read error': [
{'line': '-', 'group': '', 'desc': 'extension_is.bad is not an .ags file'}]},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -754,6 +762,7 @@
'message': 'All checks passed!',
'errors': {},
'valid': True,
'summary': [],
'additional_metadata': {},
'geojson': {
'features': [{
Expand Down Expand Up @@ -896,6 +905,7 @@
],
},
"valid": False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': 'Line 31 does not have the same number of entries as the HEADING row in TYPE.'
Expand All @@ -917,6 +927,7 @@
'desc': ''}],
},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand All @@ -934,6 +945,7 @@
'desc': ''}],
},
'valid': False,
'summary': [],
'additional_metadata': {},
'geojson': {},
'geojson_error': None
Expand Down

0 comments on commit e14f714

Please sign in to comment.