Skip to content

Silence failing tests #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# postgres-json-schema

[![Build Status](https://travis-ci.org/gavinwahl/postgres-json-schema.svg?branch=master)](https://travis-ci.org/gavinwahl/postgres-json-schema)

postgres-json-schema allows validation of [JSON
schemas](http://json-schema.org/) in PostgreSQL. It is implemented as a
PL/pgSQL function and you can use it as a check constraint to validate the
Expand Down
14 changes: 12 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@

cur = conn.cursor()

EXCLUDE = {'optional', 'refRemote.json', 'definitions.json'}
EXCLUDE_FILES = {'optional', 'refRemote.json', 'definitions.json'}
EXCLUDE_TESTS = {
# json-schema-org/JSON-Schema-Test-Suite#130
('ref.json', 'escaped pointer ref', 'percent invalid'),

# json-schema-org/JSON-Schema-Test-Suite#114
('ref.json', 'remote ref, containing refs itself', 'remote ref invalid'),
}

os.chdir('JSON-Schema-Test-Suite/tests/draft4')
failures = 0

test_files = sys.argv[1:]
if not test_files:
test_files = [test_file for test_file in os.listdir('.') if test_file not in EXCLUDE]
test_files = [test_file for test_file in os.listdir('.') if test_file not in EXCLUDE_FILES]

for test_file in test_files:
with open(test_file) as f:
suites = json.load(f)
for suite in suites:
for test in suite['tests']:
if (test_file, suite['description'], test['description']) in EXCLUDE_TESTS:
continue

def fail(e):
print("%s: validate_json_schema('%s', '%s')" % (test_file, json.dumps(suite['schema']), json.dumps(test['data'])))
print('Failed: %s: %s. %s' % (suite['description'], test['description'], e))
Expand Down