Skip to content

Commit dbea014

Browse files
committed
Fix unit tests for renamed classes
1 parent 803cea8 commit dbea014

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

tests/test_ptrtemplates.py

+34-34
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import pytest
44

55
from oascomply.ptrtemplates import (
6-
JSONPointerTemplate,
7-
InvalidJSONPointerTemplateError,
8-
JSONPointerTemplateEvaluationError,
9-
RelativeJSONPointerTemplate,
10-
InvalidRelativeJSONPointerTemplateError,
11-
RelativeJSONPointerTemplateEvaluationError,
6+
JsonPtrTemplate,
7+
InvalidJsonPtrTemplateError,
8+
JsonPtrTemplateEvaluationError,
9+
RelJsonPtrTemplate,
10+
InvalidRelJsonPtrTemplateError,
11+
RelJsonPtrTemplateEvaluationError,
1212
)
1313

1414

@@ -22,7 +22,7 @@
2222
def test_escape(unescaped, escaped):
2323
import sys
2424
sys.stderr.write(f"{unescaped!r} {escaped!r}")
25-
assert JSONPointerTemplate.escape(unescaped) == escaped
25+
assert JsonPtrTemplate.escape(unescaped) == escaped
2626

2727

2828
@pytest.mark.parametrize('escaped,unescaped', (
@@ -35,7 +35,7 @@ def test_escape(unescaped, escaped):
3535
def test_unescape(escaped, unescaped):
3636
import sys
3737
sys.stderr.write(f"{escaped!r} {unescaped!r}")
38-
assert JSONPointerTemplate.unescape(escaped) == unescaped
38+
assert JsonPtrTemplate.unescape(escaped) == unescaped
3939

4040

4141
@pytest.mark.parametrize('template_str,components', (
@@ -54,7 +54,7 @@ def test_unescape(escaped, unescaped):
5454
('/bar#', [jschon.JSONPointer('/bar#')]),
5555
))
5656
def test_constructor(template_str, components):
57-
jpt = JSONPointerTemplate(template_str)
57+
jpt = JsonPtrTemplate(template_str)
5858
assert jpt._components == components
5959

6060

@@ -68,10 +68,10 @@ def test_constructor(template_str, components):
6868
))
6969
def test_constructor_errors(template_str):
7070
with pytest.raises(
71-
InvalidJSONPointerTemplateError,
72-
match='not a valid JSONPointerTemplate',
71+
InvalidJsonPtrTemplateError,
72+
match='not a valid JsonPtrTemplate',
7373
):
74-
JSONPointerTemplate(template_str)
74+
JsonPtrTemplate(template_str)
7575

7676

7777
TEST_DOCUMENT = jschon.JSON({
@@ -85,13 +85,13 @@ def test_constructor_errors(template_str):
8585

8686
@pytest.mark.parametrize('template,output', (
8787
(
88-
JSONPointerTemplate(''),
88+
JsonPtrTemplate(''),
8989
[(jschon.JSONPointer(''), TEST_DOCUMENT, {}, None)],
9090
), (
91-
JSONPointerTemplate('/a/0'),
91+
JsonPtrTemplate('/a/0'),
9292
[(jschon.JSONPointer('/a/0'), TEST_DOCUMENT['a'][0], {}, None)],
9393
), (
94-
JSONPointerTemplate('/e/{key}'),
94+
JsonPtrTemplate('/e/{key}'),
9595
[
9696
(
9797
jschon.JSONPointer(f'/e/{key}'),
@@ -101,7 +101,7 @@ def test_constructor_errors(template_str):
101101
) for key in TEST_DOCUMENT['e']
102102
],
103103
), (
104-
JSONPointerTemplate('/e/{key}#'),
104+
JsonPtrTemplate('/e/{key}#'),
105105
[
106106
(
107107
jschon.JSONPointer(f'/e/{key}'),
@@ -111,7 +111,7 @@ def test_constructor_errors(template_str):
111111
) for key in TEST_DOCUMENT['e']
112112
],
113113
), (
114-
JSONPointerTemplate('/e/{key1}/{index}'),
114+
JsonPtrTemplate('/e/{key1}/{index}'),
115115
list(chain.from_iterable([
116116
[
117117
(
@@ -123,7 +123,7 @@ def test_constructor_errors(template_str):
123123
] for key1 in TEST_DOCUMENT['e'].keys()
124124
])),
125125
), (
126-
JSONPointerTemplate('/nope/{whatever}'),
126+
JsonPtrTemplate('/nope/{whatever}'),
127127
[],
128128
)
129129
))
@@ -140,47 +140,47 @@ def test_evaluation(template, output):
140140
('/a/0/{scalar}', 'Cannot match template variable', True),
141141
))
142142
def test_evaluation_errors(template, match, require):
143-
jpt = JSONPointerTemplate(template)
144-
with pytest.raises(JSONPointerTemplateEvaluationError, match=match):
143+
jpt = JsonPtrTemplate(template)
144+
with pytest.raises(JsonPtrTemplateEvaluationError, match=match):
145145
list(jpt.evaluate(TEST_DOCUMENT, require_match=require))
146146

147147

148148
@pytest.mark.parametrize('template_str,relptr,jptemplate', (
149149
('1+3#', jschon.RelativeJSONPointer('1+3#'), None),
150-
('0/foo', jschon.RelativeJSONPointer('0'), JSONPointerTemplate('/foo')),
150+
('0/foo', jschon.RelativeJSONPointer('0'), JsonPtrTemplate('/foo')),
151151
(
152152
'1/{bar}#',
153153
jschon.RelativeJSONPointer('1'),
154-
JSONPointerTemplate('/{bar}#'),
154+
JsonPtrTemplate('/{bar}#'),
155155
),
156156
))
157157
def test_rel_constructor(template_str, relptr, jptemplate):
158-
rjpt = RelativeJSONPointerTemplate(template_str)
158+
rjpt = RelJsonPtrTemplate(template_str)
159159
assert rjpt._relptr == relptr
160160
assert rjpt._jptemplate == jptemplate
161161

162162

163163
@pytest.mark.parametrize('template_str,match', (
164164
('0#/foo', "Can't use '#'"),
165-
('stuff/nonsense', 'not a valid RelativeJSONPointerTemplate'),
166-
('0/{bar}#/foo', 'not a valid RelativeJSONPointerTemplate'),
165+
('stuff/nonsense', 'not a valid RelJsonPtrTemplate'),
166+
('0/{bar}#/foo', 'not a valid RelJsonPtrTemplate'),
167167
))
168168
def test_rel_constructor_errors(template_str, match):
169-
with pytest.raises(InvalidRelativeJSONPointerTemplateError, match=match):
170-
RelativeJSONPointerTemplate(template_str)
169+
with pytest.raises(InvalidRelJsonPtrTemplateError, match=match):
170+
RelJsonPtrTemplate(template_str)
171171

172172

173173
@pytest.mark.parametrize('template,start,output', (
174174
(
175-
RelativeJSONPointerTemplate('0+1'),
175+
RelJsonPtrTemplate('0+1'),
176176
jschon.JSONPointer('/a/1').evaluate(TEST_DOCUMENT),
177177
[(jschon.RelativeJSONPointer('0+1'), TEST_DOCUMENT['a'][2], {}, None)],
178178
), (
179-
RelativeJSONPointerTemplate('1#'),
179+
RelJsonPtrTemplate('1#'),
180180
jschon.JSONPointer('/e/f').evaluate(TEST_DOCUMENT),
181181
[(jschon.RelativeJSONPointer('1#'), TEST_DOCUMENT['e'], {}, 'e')],
182182
), (
183-
RelativeJSONPointerTemplate('0/{var}'),
183+
RelJsonPtrTemplate('0/{var}'),
184184
jschon.JSONPointer('/e/i').evaluate(TEST_DOCUMENT),
185185
[
186186
(
@@ -197,7 +197,7 @@ def test_rel_constructor_errors(template_str, match):
197197
),
198198
],
199199
), (
200-
RelativeJSONPointerTemplate('0/nope/{whatever}'),
200+
RelJsonPtrTemplate('0/nope/{whatever}'),
201201
TEST_DOCUMENT,
202202
[],
203203
)
@@ -208,17 +208,17 @@ def test_rel_evaluation(template, start, output):
208208

209209
@pytest.mark.parametrize('template,start,match,require', (
210210
(
211-
RelativeJSONPointerTemplate('1/{whatever}'),
211+
RelJsonPtrTemplate('1/{whatever}'),
212212
TEST_DOCUMENT,
213213
'Could not evaluate origin',
214214
False,
215215
), (
216-
RelativeJSONPointerTemplate('0/x'),
216+
RelJsonPtrTemplate('0/x'),
217217
TEST_DOCUMENT,
218218
r'Path .* not found .* \(after applying',
219219
True,
220220
)
221221
))
222222
def test_rel_evaluation_errors(template, start, match, require):
223-
with pytest.raises(RelativeJSONPointerTemplateEvaluationError, match=match):
223+
with pytest.raises(RelJsonPtrTemplateEvaluationError, match=match):
224224
list(template.evaluate(start, require_match=require))

0 commit comments

Comments
 (0)