Skip to content

Commit

Permalink
Test remote references.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Feb 22, 2013
1 parent 5ab724c commit 65a0e17
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests.py
Expand Up @@ -5,6 +5,7 @@
import json
import os
import re
import subprocess
import sys

if sys.version_info[:2] < (2, 7): # pragma: no cover
Expand All @@ -30,7 +31,9 @@

THIS_DIR = os.path.dirname(__file__)
TESTS_DIR = os.path.join(THIS_DIR, "json", "tests")

JSONSCHEMA_SUITE = os.path.join(THIS_DIR, "json", "bin", "jsonschema_suite")
REMOTES = json.loads(subprocess.check_output([JSONSCHEMA_SUITE, "remotes"]))


def make_case(schema, data, valid):
Expand Down Expand Up @@ -168,6 +171,22 @@ def test_minItems_invalid_string(self):
validate([1], {"minItems" : "1"}) # needs to be an integer


@load_json_cases("draft3/refRemote.json")
class TestDraft3RemoteRefResolution(unittest.TestCase):

validator_class = Draft3Validator

def setUp(self):
patch = mock.patch("jsonschema.requests")
requests = patch.start()
requests.get.side_effect = self.resolve
self.addCleanup(patch.stop)

def resolve(self, reference):
_, _, reference = reference.partition("http://localhost:1234/")
return mock.Mock(**{"json.return_value" : REMOTES.get(reference)})


class TestIterErrors(unittest.TestCase):
def setUp(self):
self.validator = Draft3Validator({})
Expand Down

0 comments on commit 65a0e17

Please sign in to comment.