summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKenn Knowles <kenn.knowles@gmail.com>2013-03-14 16:47:17 -0400
committerKenn Knowles <kenn.knowles@gmail.com>2013-03-14 16:47:17 -0400
commit2831d2b692b058d5c1f82746f7293e8de976697f (patch)
treecca28c7fbd696706396ceea099078aed71707510 /tests
parent340e4500ad66a84a987a768d3cd3f37c0e5c5c27 (diff)
downloadjsonpath-rw-2831d2b692b058d5c1f82746f7293e8de976697f.tar.gz
Add path followed info and restore previous test passing
Diffstat (limited to 'tests')
-rw-r--r--tests/test_jsonpath.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_jsonpath.py b/tests/test_jsonpath.py
index 7e7437e..df4af06 100644
--- a/tests/test_jsonpath.py
+++ b/tests/test_jsonpath.py
@@ -16,15 +16,26 @@ class TestJsonPath(unittest.TestCase):
print 'parse("%s").find(%s) =?= %s' % (string, data, target)
result = parse(string).find(data)
if isinstance(target, list):
- assert list(result) == target
+ assert [r.value for r in result] == target
else:
- assert result == target
+ assert result.value == target
def test_fields(self):
self.check_cases([ ('foo', {'foo': 'baz'}, ['baz']),
('foo,baz', {'foo': 1, 'baz': 2}, [1, 2]),
('*', {'foo': 1, 'baz': 2}, [1, 2]) ])
+ def test_magic_id(self):
+ self.check_cases([
+ ('id', {'id': 'baz'}, ['baz']),
+ # ('id', {}, '@'),
+ #('id', {}, '@'),
+ # ('foo.id', {'foo': {}}, ['foo']),
+ # ('foo[*].id', {'foo': {}}, 'foo[0]'),
+ # ('foo.baz.id', {'foo': {'baz': {}}}, ['foo.baz']),
+ # ('foo.id', [{'foo': {}}, {'foo': {}}], ['foo[0]', 'foo[1]'])
+ ])
+
def test_index(self):
self.check_cases([('[0]', [42], [42]),
('[2]', [34, 65, 29, 59], [29])])