Skip to content

Commit 583ecf9

Browse files
committed
Add name.json to the CLI tool's remotes.
Also fix the test that was trying to ensure that this wouldn't happen (it was only checking that no new ones were added in-line that didn't live on the filesystem, so now check in both directions). Right now, remotes are maintained in both of these places, which is a bit non-ideal, but that's the status quo. The right actual fix here is probably to remove the in-memory schemas and serve off the filesystem for the `remotes` command (and use shutil.copytree for dumping).
1 parent 67c7b4d commit 583ecf9

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

bin/jsonschema_suite

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@ else:
3838
)
3939

4040

41-
ROOT_DIR = os.path.join(
42-
os.path.dirname(__file__), os.pardir).rstrip("__pycache__")
41+
ROOT_DIR = os.path.abspath(
42+
os.path.join(os.path.dirname(__file__), os.pardir).rstrip("__pycache__"),
43+
)
4344
SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
4445

4546
REMOTES = {
46-
"integer.json": {"type": "integer"},
47+
"integer.json": {u"type": u"integer"},
48+
"name.json": {
49+
u"type": "string",
50+
u"definitions": {
51+
u"orNull": {u"anyOf": [{u"type": u"null"}, {u"$ref": u"#"}]},
52+
},
53+
},
4754
"subSchemas.json": {
48-
"integer": {"type": "integer"},
49-
"refToInteger": {"$ref": "#/integer"},
55+
u"integer": {u"type": u"integer"},
56+
u"refToInteger": {u"$ref": u"#/integer"},
5057
},
51-
"folder/folderInteger.json": {"type": "integer"}
58+
"folder/folderInteger.json": {u"type": u"integer"}
5259
}
5360
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
5461

@@ -139,10 +146,19 @@ class SanityTests(unittest.TestCase):
139146
self.fail(str(error))
140147

141148
def test_remote_schemas_are_updated(self):
142-
for url, schema in REMOTES.items():
143-
filepath = os.path.join(REMOTES_DIR, url)
144-
with open(filepath) as schema_file:
145-
self.assertEqual(json.load(schema_file), schema)
149+
files = {}
150+
for parent, _, paths in os.walk(REMOTES_DIR):
151+
for path in paths:
152+
absolute_path = os.path.join(parent, path)
153+
with open(absolute_path) as schema_file:
154+
files[absolute_path] = json.load(schema_file)
155+
156+
self.assertEqual(
157+
files, {
158+
os.path.join(REMOTES_DIR, path): contents
159+
for path, contents in REMOTES.iteritems()
160+
},
161+
)
146162

147163

148164
def main(arguments):

0 commit comments

Comments
 (0)