Skip to content

Commit

Permalink
Merge pull request #4 from datosgobar/path-issues-#1
Browse files Browse the repository at this point in the history
closes #1
  • Loading branch information
abenassi committed Nov 30, 2016
2 parents 8076670 + 2bf4aa4 commit 6159d06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 6 additions & 4 deletions pydatajson/pydatajson.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement
from distutils.sysconfig import get_python_lib
import os
import os.path
from urlparse import urljoin
import json
import jsonschema
import requests

ABSOLUTE_PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))


class DataJson(object):
"""Métodos para trabajar con archivos data.json."""

# Variables por default
ABSOLUTE_SCHEMA_DIR = os.path.join(get_python_lib(), "pydatajson/schemas")
ABSOLUTE_SCHEMA_DIR = os.path.join(ABSOLUTE_PROJECT_DIR, "schemas")
DEFAULT_CATALOG_SCHEMA_FILENAME = "catalog.json"

def __init__(self,
Expand Down Expand Up @@ -69,7 +71,7 @@ def _create_validator(cls, schema_filename, schema_dir):
# Según https://github.com/Julian/jsonschema/issues/98
# Permite resolver referencias locales a otros esquemas.
resolver = jsonschema.RefResolver(
base_uri=("file://" + schema_dir + '/'), referrer=schema)
base_uri=urljoin('file:', schema_path), referrer=schema)

validator = jsonschema.Draft4Validator(
schema=schema, resolver=resolver)
Expand Down
7 changes: 3 additions & 4 deletions tests/test_pydatajson.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,10 @@ def test_validate_catalog_remote_datajson(self):
""" Testea `validate_catalog` contra un data.json remoto."""

exp = {
"status": "ERROR",
"status": "OK",
"error": {
"catalog": ["Título del portal"],
"dataset": ["Dataset ejemplo 04", "Dataset ejemplo 03",
"Dataset ejemplo 02", "Dataset ejemplo 01"]
"catalog": [],
"dataset": []
}
}

Expand Down

0 comments on commit 6159d06

Please sign in to comment.