pytest-jsonschema-snapshot 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytest_jsonschema_snapshot/__init__.py +1 -1
- pytest_jsonschema_snapshot/core.py +25 -13
- {pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/METADATA +2 -1
- {pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/RECORD +7 -7
- {pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/WHEEL +0 -0
- {pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/entry_points.txt +0 -0
- {pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -233,24 +233,33 @@ class SchemaShot:
|
|
|
233
233
|
# --- схема уже была: сравнение и валидация --------------------------------
|
|
234
234
|
schema_updated = False
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
def merge_schemas(old: dict, new: dict) -> dict:
|
|
237
|
+
builder = JsonToSchemaConverter(
|
|
238
|
+
format_mode=self.format_mode # type: ignore[arg-type]
|
|
239
|
+
) # , examples=self.examples_limit)
|
|
240
|
+
builder.add_schema(old)
|
|
241
|
+
builder.add_schema(new)
|
|
242
|
+
return builder.to_schema()
|
|
238
243
|
|
|
244
|
+
if existing_schema != current_schema: # есть отличия
|
|
239
245
|
if (self.update_mode or self.reset_mode) and self.update_actions.get("update"):
|
|
240
|
-
GLOBAL_STATS.add_updated(schema_path.name, differences)
|
|
241
|
-
|
|
242
246
|
# обновляем файл
|
|
243
247
|
if self.reset_mode and not self.update_mode:
|
|
248
|
+
differences = self.differ.compare(
|
|
249
|
+
dict(existing_schema), current_schema
|
|
250
|
+
).render()
|
|
251
|
+
GLOBAL_STATS.add_updated(schema_path.name, differences)
|
|
252
|
+
|
|
244
253
|
with open(schema_path, "w", encoding="utf-8") as f:
|
|
245
254
|
json.dump(current_schema, f, indent=2, ensure_ascii=False)
|
|
246
255
|
self.logger.warning(f"Schema `{name}` updated (reset).\n\n{differences}")
|
|
247
256
|
elif self.update_mode and not self.reset_mode:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
merged_schema = merge_schemas(existing_schema, current_schema)
|
|
258
|
+
|
|
259
|
+
differences = self.differ.compare(
|
|
260
|
+
dict(existing_schema), merged_schema
|
|
261
|
+
).render()
|
|
262
|
+
GLOBAL_STATS.add_updated(schema_path.name, differences)
|
|
254
263
|
|
|
255
264
|
with open(schema_path, "w", encoding="utf-8") as f:
|
|
256
265
|
json.dump(merged_schema, f, indent=2, ensure_ascii=False)
|
|
@@ -262,6 +271,9 @@ class SchemaShot:
|
|
|
262
271
|
)
|
|
263
272
|
schema_updated = True
|
|
264
273
|
elif data is not None:
|
|
274
|
+
merged_schema = merge_schemas(existing_schema, current_schema)
|
|
275
|
+
|
|
276
|
+
differences = self.differ.compare(dict(existing_schema), merged_schema).render()
|
|
265
277
|
GLOBAL_STATS.add_uncommitted(schema_path.name, differences)
|
|
266
278
|
|
|
267
279
|
# только валидируем по старой схеме
|
|
@@ -284,9 +296,9 @@ class SchemaShot:
|
|
|
284
296
|
format_checker=FormatChecker(),
|
|
285
297
|
)
|
|
286
298
|
except ValidationError as e:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
).render()
|
|
299
|
+
merged_schema = merge_schemas(existing_schema, current_schema)
|
|
300
|
+
|
|
301
|
+
differences = self.differ.compare(dict(existing_schema), merged_schema).render()
|
|
290
302
|
pytest.fail(f"\n\n{differences}\n\nValidation error in `{name}`: {e.message}")
|
|
291
303
|
|
|
292
304
|
return name, schema_updated
|
{pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-jsonschema-snapshot
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Pytest plugin for automatic JSON Schema generation and validation from examples
|
|
5
5
|
Project-URL: Homepage, https://miskler.github.io/pytest-jsonschema-snapshot/basic/quick_start.html
|
|
6
6
|
Project-URL: Repository, https://github.com/Miskler/pytest-jsonschema-snapshot
|
|
@@ -58,6 +58,7 @@ Description-Content-Type: text/markdown
|
|
|
58
58
|
[](https://pypi.org/project/pytest-jsonschema-snapshot/)
|
|
59
59
|
[](LICENSE)
|
|
60
60
|
[](https://github.com/psf/black)
|
|
61
|
+
[](https://pycqa.github.io/isort/)
|
|
61
62
|
[](https://mypy.readthedocs.io/en/stable/index.html)
|
|
62
63
|
[](https://discord.gg/UnJnGHNbBp)
|
|
63
64
|
[](https://t.me/miskler_dev)
|
{pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/RECORD
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
pytest_jsonschema_snapshot/__init__.py,sha256=
|
|
2
|
-
pytest_jsonschema_snapshot/core.py,sha256=
|
|
1
|
+
pytest_jsonschema_snapshot/__init__.py,sha256=v-YeeYwLr0JgBV0W2iNt8SEfBDFnP0TivliTh8btZYc,385
|
|
2
|
+
pytest_jsonschema_snapshot/core.py,sha256=CoL_W-u6o3N7XDwv-MbePJiZaGX0LtGS6BLbj9MHROU,11995
|
|
3
3
|
pytest_jsonschema_snapshot/plugin.py,sha256=nvAfxtLSX_B5FzaWu7DfsiWRxFjxDvnQNNOhkRrRnbw,8677
|
|
4
4
|
pytest_jsonschema_snapshot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
pytest_jsonschema_snapshot/stats.py,sha256=XGGzHY0ytMFOkFpnqNAK1DpV9iI0_fZPWrVvHFNFL3g,7943
|
|
@@ -8,8 +8,8 @@ pytest_jsonschema_snapshot/tools/name_maker.py,sha256=tqss8NCGSo2aQX_-RkCJzy3NJx
|
|
|
8
8
|
pytest_jsonschema_snapshot/tools/genson_addon/__init__.py,sha256=nANkqHTaWTZPwBDztsnQvObHUZLSeHenJS--oWfep8c,92
|
|
9
9
|
pytest_jsonschema_snapshot/tools/genson_addon/format_detector.py,sha256=Wc5pB_xstyr4OtjwJ2qqmV62xET63cN7Nb0gxkrYyW0,1636
|
|
10
10
|
pytest_jsonschema_snapshot/tools/genson_addon/to_schema_converter.py,sha256=UdQIkZhMrTJNHwI1B1dv3aEwx41B1B_lLyr4KWiUpNY,4168
|
|
11
|
-
pytest_jsonschema_snapshot-0.2.
|
|
12
|
-
pytest_jsonschema_snapshot-0.2.
|
|
13
|
-
pytest_jsonschema_snapshot-0.2.
|
|
14
|
-
pytest_jsonschema_snapshot-0.2.
|
|
15
|
-
pytest_jsonschema_snapshot-0.2.
|
|
11
|
+
pytest_jsonschema_snapshot-0.2.3.dist-info/METADATA,sha256=cMTeW3ydl2gg8dQHUqmsiLSa9l9ndSoQP5yUlzktOn4,7795
|
|
12
|
+
pytest_jsonschema_snapshot-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
13
|
+
pytest_jsonschema_snapshot-0.2.3.dist-info/entry_points.txt,sha256=eJ1x4TMmhcc8YtM7IoCsUJO4-rLeTrGy8tPgkrojjKs,58
|
|
14
|
+
pytest_jsonschema_snapshot-0.2.3.dist-info/licenses/LICENSE,sha256=1HRFdSzlJ4BtHv6U7tZun3iCArjbCnm5NUowE9hZpNs,1071
|
|
15
|
+
pytest_jsonschema_snapshot-0.2.3.dist-info/RECORD,,
|
{pytest_jsonschema_snapshot-0.2.1.dist-info → pytest_jsonschema_snapshot-0.2.3.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|