Skip to content

Commit 65a0e17

Browse files
committed
Test remote references.
1 parent 5ab724c commit 65a0e17

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import os
77
import re
8+
import subprocess
89
import sys
910

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

3132
THIS_DIR = os.path.dirname(__file__)
3233
TESTS_DIR = os.path.join(THIS_DIR, "json", "tests")
34+
3335
JSONSCHEMA_SUITE = os.path.join(THIS_DIR, "json", "bin", "jsonschema_suite")
36+
REMOTES = json.loads(subprocess.check_output([JSONSCHEMA_SUITE, "remotes"]))
3437

3538

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

170173

174+
@load_json_cases("draft3/refRemote.json")
175+
class TestDraft3RemoteRefResolution(unittest.TestCase):
176+
177+
validator_class = Draft3Validator
178+
179+
def setUp(self):
180+
patch = mock.patch("jsonschema.requests")
181+
requests = patch.start()
182+
requests.get.side_effect = self.resolve
183+
self.addCleanup(patch.stop)
184+
185+
def resolve(self, reference):
186+
_, _, reference = reference.partition("http://localhost:1234/")
187+
return mock.Mock(**{"json.return_value" : REMOTES.get(reference)})
188+
189+
171190
class TestIterErrors(unittest.TestCase):
172191
def setUp(self):
173192
self.validator = Draft3Validator({})

0 commit comments

Comments
 (0)