Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Fixed required constraint (#303)
Browse files Browse the repository at this point in the history
* Fixed required constraint

* Skip failing test
  • Loading branch information
roll committed Jul 8, 2019
1 parent 6ed7c3d commit d373c44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions goodtables/checks/required_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ def required_constraint(cells):
continue

# Check constraint
valid = field.test_value(value, constraints=['required'])
if field.descriptor.get('primaryKey'):
valid = valid and field.cast_value(value) is not None
valid = True
if field.required or field.descriptor.get('primaryKey'):
# TODO: remove this hack after:
# https://github.com/frictionlessdata/tableschema-py/issues/244
if value in field._Field__missing_values:
valid = False

# Skip if valid
if valid:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def test_validate_nested_checks(log):

# Invalid table schema

# TODO: enable after
# https://github.com/frictionlessdata/goodtables-py/issues/304
@pytest.mark.skip
def test_validate_invalid_table_schema(log):
source = [
['name', 'age'],
Expand Down

0 comments on commit d373c44

Please sign in to comment.