Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/test_jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,3 +969,38 @@ def test_no_initial_context_and_with_skip_expand_does_not_drop_property_when_arr
compacted = jsonld.compact(input, {"@vocab": "http://example.org#"}, {"skipExpansion": True})
expected = {"@context": {"@vocab": "http://example.org#"}, "name": "Bob"}
assert compacted == expected

# Issue 83
def test_with_vocab_no_id(self):
"""
Compacting with @vocab should not compact a plain string value
"""
ctx = {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}}
input = {
'http://ex.org/#path': 'http://ex.org/#shortname',
}
expected = {
"@context": {"@vocab": "http://ex.org/#", "path": {"@type": "@id"}},
"http://ex.org/#path": "http://ex.org/#shortname",
}

compacted = jsonld.compact(input, ctx)

assert compacted == expected

def test_with_vocab_with_id(self):
"""
Compacting with @vocab should compact an @id value
"""
ctx = {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}}
input = {
'http://ex.org/#path': {'@id': 'http://ex.org/#shortname'},
}
expected = {
"@context": {"@vocab": "http://ex.org/#", "path": {"@type": "@id"}},
"path": "http://ex.org/#shortname",
}

compacted = jsonld.compact(input, ctx)

assert compacted == expected
Loading