|
1 | 1 | import copy
|
2 |
| -from collections import namedtuple |
3 | 2 | from contextlib import nullcontext as does_not_raise
|
4 | 3 |
|
5 | 4 | import pytest
|
6 | 5 |
|
7 | 6 | from jsonpath_ng.ext import parse
|
8 | 7 |
|
9 |
| -Params = namedtuple('Params', 'string initial_data insert_val target') |
10 |
| - |
11 | 8 |
|
12 | 9 | @pytest.mark.parametrize(
|
13 | 10 | "string, initial_data, expected_result",
|
@@ -70,40 +67,3 @@ def test_unsupported_classes(string, initial_data, expectation):
|
70 | 67 | with expectation:
|
71 | 68 | result = jsonpath.update_or_create(initial_data, 42)
|
72 | 69 | assert result != copied_initial_data
|
73 |
| - |
74 |
| - |
75 |
| -@pytest.mark.parametrize('string, initial_data, insert_val, target', [ |
76 |
| -
|
77 |
| - Params(string='$.name[0].text', |
78 |
| - initial_data={}, |
79 |
| - insert_val='Sir Michael', |
80 |
| - target={'name': [{'text': 'Sir Michael'}]}), |
81 |
| -
|
82 |
| - Params(string='$.name[0].given[0]', |
83 |
| - initial_data={'name': [{'text': 'Sir Michael'}]}, |
84 |
| - insert_val='Michael', |
85 |
| - target={'name': [{'text': 'Sir Michael', |
86 |
| - 'given': ['Michael']}]}), |
87 |
| -
|
88 |
| - Params(string='$.name[0].prefix[0]', |
89 |
| - initial_data={'name': [{'text': 'Sir Michael', |
90 |
| - 'given': ['Michael']}]}, |
91 |
| - insert_val='Sir', |
92 |
| - target={'name': [{'text': 'Sir Michael', |
93 |
| - 'given': ['Michael'], |
94 |
| - 'prefix': ['Sir']}]}), |
95 |
| -
|
96 |
| - Params(string='$.birthDate', |
97 |
| - initial_data={'name': [{'text': 'Sir Michael', |
98 |
| - 'given': ['Michael'], |
99 |
| - 'prefix': ['Sir']}]}, |
100 |
| - insert_val='1943-05-05', |
101 |
| - target={'name': [{'text': 'Sir Michael', |
102 |
| - 'given': ['Michael'], |
103 |
| - 'prefix': ['Sir']}], |
104 |
| - 'birthDate': '1943-05-05'}), |
105 |
| -]) |
106 |
| -def test_build_doc(string, initial_data, insert_val, target): |
107 |
| - jsonpath = parse(string) |
108 |
| - result = jsonpath.update_or_create(initial_data, insert_val) |
109 |
| - assert result == target |
0 commit comments