Skip to content

Commit

Permalink
feat: Remove get_invalid_csv_files
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jun 15, 2023
1 parent da6e031 commit a1e3b41
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 40 deletions.
9 changes: 8 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.2.2 (2023-06-14)
------------------

Removed
~~~~~~~

- :meth:`~jscc.testing.checks.get_invalid_csv_files`, as Python's CSV parser errors only if the CSV dialect is configured.

0.2.1 (2023-06-14)
------------------

Expand Down Expand Up @@ -129,7 +137,6 @@ Added
~~~~~

- :meth:`jscc.schema.extend_schema`
- :meth:`jscc.testing.checks.get_invalid_csv_files`

Changed
~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
author = "Open Contracting Partnership and Open Data Services Co-operative Limited"

# The short X.Y version
version = "0.2.1"
version = "0.2.2"
# The full version, including alpha/beta/rc tags
release = version

Expand Down
24 changes: 0 additions & 24 deletions jscc/testing/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,30 +210,6 @@ def test_invalid_json():
yield path, e


def get_invalid_csv_files(**kwargs):
"""
Yields the path and exception (as a tuple) of any CSV file that isn't valid.
CSV files must be parsed without error by the ``csv`` module.
pytest example::
from jscc.testing.checks import get_invalid_csv_files
from jscc.testing.util import warn_and_assert
def test_invalid_csv():
warn_and_assert(get_invalid_csv_files(), '{0} is not valid CSV: {1}',
'CSV files are invalid. See warnings below.')
"""
for path, name in walk(**kwargs):
if path.endswith('.csv'):
with open(path, newline='') as f:
try:
csv.DictReader(f)
except csv.Error as e:
yield path, e


def validate_schema(path, data, validator):
"""
Warns and returns the number of errors relating to JSON Schema validation.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = jscc
version = 0.2.1
version = 0.2.2
author = Open Contracting Partnership and Open Data Services Co-operative Limited
author_email = data@open-contracting.org
license = BSD
Expand Down
14 changes: 1 addition & 13 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import jscc.testing.checks
from jscc.exceptions import DuplicateKeyError
from jscc.testing.checks import (get_empty_files, get_invalid_csv_files, get_invalid_json_files, get_misindented_files,
from jscc.testing.checks import (get_empty_files, get_invalid_json_files, get_misindented_files,
validate_codelist_enum, validate_object_id, validate_ref,
validate_schema_codelists_match)
from tests import parse, path
Expand Down Expand Up @@ -87,18 +87,6 @@ def test_get_invalid_json_files():
assert str(results['invalid.json']) == 'Expecting property name enclosed in double quotes: line 2 column 1 (char 2)' # noqa: E501


def test_get_invalid_csv_files():
directory = os.path.realpath(path('csv'))
with chdir(directory):
results = {}
for result in get_invalid_csv_files():
results[result[0].replace(directory, '')] = result[1]

assert len(result) == 2

assert len(results) == 0


def test_validate_codelist_enum():
directory = os.path.realpath(path('schema')) + os.sep
with chdir(directory):
Expand Down

0 comments on commit a1e3b41

Please sign in to comment.