|
5 | 5 | import json |
6 | 6 | import os |
7 | 7 | import re |
| 8 | +import subprocess |
8 | 9 | import sys |
9 | 10 |
|
10 | 11 | if sys.version_info[:2] < (2, 7): # pragma: no cover |
|
30 | 31 |
|
31 | 32 | THIS_DIR = os.path.dirname(__file__) |
32 | 33 | TESTS_DIR = os.path.join(THIS_DIR, "json", "tests") |
| 34 | + |
33 | 35 | JSONSCHEMA_SUITE = os.path.join(THIS_DIR, "json", "bin", "jsonschema_suite") |
| 36 | +REMOTES = json.loads(subprocess.check_output([JSONSCHEMA_SUITE, "remotes"])) |
34 | 37 |
|
35 | 38 |
|
36 | 39 | def make_case(schema, data, valid): |
@@ -168,6 +171,22 @@ def test_minItems_invalid_string(self): |
168 | 171 | validate([1], {"minItems" : "1"}) # needs to be an integer |
169 | 172 |
|
170 | 173 |
|
| 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 | + |
171 | 190 | class TestIterErrors(unittest.TestCase): |
172 | 191 | def setUp(self): |
173 | 192 | self.validator = Draft3Validator({}) |
|
0 commit comments