summaryrefslogtreecommitdiffstats
path: root/tests/test_jsonpath.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-13 11:11:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-13 11:11:42 +0000
commit721d458d4c24741ccbc5519b7ca39234a1a21ff6 (patch)
treeb9f72e1d00aba012f06cdf7b0d75ec5e53640eaf /tests/test_jsonpath.py
parentAdding upstream version 25.1.0. (diff)
downloadsqlglot-721d458d4c24741ccbc5519b7ca39234a1a21ff6.tar.xz
sqlglot-721d458d4c24741ccbc5519b7ca39234a1a21ff6.zip
Adding upstream version 25.5.1.upstream/25.5.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_jsonpath.py')
-rw-r--r--tests/test_jsonpath.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_jsonpath.py b/tests/test_jsonpath.py
index 4daf3c1..c939c52 100644
--- a/tests/test_jsonpath.py
+++ b/tests/test_jsonpath.py
@@ -2,8 +2,9 @@ import json
import os
import unittest
-from sqlglot import exp, jsonpath
+from sqlglot import exp
from sqlglot.errors import ParseError, TokenError
+from sqlglot.jsonpath import parse
from tests.helpers import FIXTURES_DIR
@@ -25,7 +26,7 @@ class TestJsonpath(unittest.TestCase):
exp.JSONPathSelector(this=exp.JSONPathScript(this="@.x)")),
]
self.assertEqual(
- jsonpath.parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"),
+ parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"),
exp.JSONPath(expressions=expected_expressions),
)
@@ -36,7 +37,7 @@ class TestJsonpath(unittest.TestCase):
("$[((@.length-1))]", "$[((@.length-1))]"),
):
with self.subTest(f"{selector} -> {expected}"):
- self.assertEqual(jsonpath.parse(selector).sql(), f"'{expected}'")
+ self.assertEqual(parse(selector).sql(), f"'{expected}'")
def test_cts_file(self):
with open(os.path.join(FIXTURES_DIR, "jsonpath", "cts.json")) as file:
@@ -131,9 +132,9 @@ class TestJsonpath(unittest.TestCase):
with self.subTest(f"{selector.strip()} /* {test['name']} */"):
if test.get("invalid_selector"):
try:
- jsonpath.parse(selector)
+ parse(selector)
except (ParseError, TokenError):
pass
else:
- path = jsonpath.parse(selector)
+ path = parse(selector)
self.assertEqual(path.sql(), f"'{overrides.get(selector, selector)}'")