pytest-jsonschema-snapshot 0.2.2__tar.gz → 0.2.3__tar.gz

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.
Files changed (75) hide show
  1. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/PKG-INFO +2 -1
  2. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/README.md +1 -0
  3. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/__init__.py +1 -1
  4. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/core.py +15 -12
  5. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.flake8 +0 -0
  6. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  7. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  8. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/ISSUE_TEMPLATE/documentation_issue.yml +0 -0
  9. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  10. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/PULL_REQUEST_TEMPLATE/general.md +0 -0
  11. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/actions/build-docs/action.yml +0 -0
  12. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/workflows/release.yml +0 -0
  13. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/workflows/reusable-test.yml +0 -0
  14. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.github/workflows/test.yml +0 -0
  15. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/.gitignore +0 -0
  16. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/LICENSE +0 -0
  17. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/Makefile +0 -0
  18. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/assets/logo.png +0 -0
  19. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/docs/source/_static/logo_day.png +0 -0
  20. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/docs/source/_static/logo_night.png +0 -0
  21. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/docs/source/basic/quick_start.rst +0 -0
  22. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/docs/source/conf.py +0 -0
  23. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/docs/source/index.rst +0 -0
  24. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pyproject.toml +0 -0
  25. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/plugin.py +0 -0
  26. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/py.typed +0 -0
  27. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/stats.py +0 -0
  28. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/tools/__init__.py +0 -0
  29. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/tools/genson_addon/__init__.py +0 -0
  30. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/tools/genson_addon/format_detector.py +0 -0
  31. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/tools/genson_addon/to_schema_converter.py +0 -0
  32. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/pytest_jsonschema_snapshot/tools/name_maker.py +0 -0
  33. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/reinstall_plugin.sh +0 -0
  34. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/requirements.txt +0 -0
  35. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/test_stats.py +0 -0
  36. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/tools/genson_addon/test_format_safe.py +0 -0
  37. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/tools/test_name_maker.py +0 -0
  38. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/TestDataClass.get_data.first.json +0 -0
  39. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/TestDataClass.get_data.first.schema.json +0 -0
  40. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/TestDataClass.get_data.json +0 -0
  41. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/TestDataClass.get_data.schema.json +0 -0
  42. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/array_formats_test.json +0 -0
  43. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/array_formats_test.schema.json +0 -0
  44. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/date_test.json +0 -0
  45. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/date_test.schema.json +0 -0
  46. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/datetime_test.json +0 -0
  47. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/datetime_test.schema.json +0 -0
  48. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/email_test.json +0 -0
  49. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/email_test.schema.json +0 -0
  50. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/get_data.first.json +0 -0
  51. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/get_data.first.schema.json +0 -0
  52. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/get_data.json +0 -0
  53. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/get_data.schema.json +0 -0
  54. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/ipv4_test.json +0 -0
  55. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/ipv4_test.schema.json +0 -0
  56. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/mixed_formats_test.json +0 -0
  57. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/mixed_formats_test.schema.json +0 -0
  58. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/multi_schema_one.json +0 -0
  59. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/multi_schema_three.json +0 -0
  60. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/multi_schema_two.json +0 -0
  61. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/regular_strings_test.json +0 -0
  62. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/regular_strings_test.schema.json +0 -0
  63. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/some_schema.json +0 -0
  64. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/some_schema.schema.json +0 -0
  65. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/strict_email_validation_test.json +0 -0
  66. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/strict_email_validation_test.schema.json +0 -0
  67. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/uri_test.json +0 -0
  68. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/uri_test.schema.json +0 -0
  69. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/uuid_test.json +0 -0
  70. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/__snapshots__/uuid_test.schema.json +0 -0
  71. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/test_base.py +0 -0
  72. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/test_base_name_callable.py +0 -0
  73. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/test_format_detection.py +0 -0
  74. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/test_format_validation.py +0 -0
  75. {pytest_jsonschema_snapshot-0.2.2 → pytest_jsonschema_snapshot-0.2.3}/tests/usage/test_multiple_schema_creation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-jsonschema-snapshot
3
- Version: 0.2.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
  [![PyPI - Package Version](https://img.shields.io/pypi/v/pytest-jsonschema-snapshot?color=blue)](https://pypi.org/project/pytest-jsonschema-snapshot/)
59
59
  [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
60
60
  [![BlackCode](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)
61
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
61
62
  [![mypy](https://img.shields.io/badge/type--checked-mypy-blue?logo=python)](https://mypy.readthedocs.io/en/stable/index.html)
62
63
  [![Discord](https://img.shields.io/discord/792572437292253224?label=Discord&labelColor=%232c2f33&color=%237289da)](https://discord.gg/UnJnGHNbBp)
63
64
  [![Telegram](https://img.shields.io/badge/Telegram-24A1DE)](https://t.me/miskler_dev)
@@ -13,6 +13,7 @@
13
13
  [![PyPI - Package Version](https://img.shields.io/pypi/v/pytest-jsonschema-snapshot?color=blue)](https://pypi.org/project/pytest-jsonschema-snapshot/)
14
14
  [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
15
15
  [![BlackCode](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)
16
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
16
17
  [![mypy](https://img.shields.io/badge/type--checked-mypy-blue?logo=python)](https://mypy.readthedocs.io/en/stable/index.html)
17
18
  [![Discord](https://img.shields.io/discord/792572437292253224?label=Discord&labelColor=%232c2f33&color=%237289da)](https://discord.gg/UnJnGHNbBp)
18
19
  [![Telegram](https://img.shields.io/badge/Telegram-24A1DE)](https://t.me/miskler_dev)
@@ -8,5 +8,5 @@ pytest-typed-schema-shot
8
8
 
9
9
  from .core import SchemaShot
10
10
 
11
- __version__ = "0.2.2"
11
+ __version__ = "0.2.3"
12
12
  __all__ = ["SchemaShot"]
@@ -233,6 +233,14 @@ class SchemaShot:
233
233
  # --- схема уже была: сравнение и валидация --------------------------------
234
234
  schema_updated = False
235
235
 
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()
243
+
236
244
  if existing_schema != current_schema: # есть отличия
237
245
  if (self.update_mode or self.reset_mode) and self.update_actions.get("update"):
238
246
  # обновляем файл
@@ -246,12 +254,7 @@ class SchemaShot:
246
254
  json.dump(current_schema, f, indent=2, ensure_ascii=False)
247
255
  self.logger.warning(f"Schema `{name}` updated (reset).\n\n{differences}")
248
256
  elif self.update_mode and not self.reset_mode:
249
- builder = JsonToSchemaConverter(
250
- format_mode=self.format_mode # type: ignore[arg-type]
251
- ) # , examples=self.examples_limit)
252
- builder.add_schema(existing_schema)
253
- builder.add_schema(current_schema)
254
- merged_schema = builder.to_schema()
257
+ merged_schema = merge_schemas(existing_schema, current_schema)
255
258
 
256
259
  differences = self.differ.compare(
257
260
  dict(existing_schema), merged_schema
@@ -268,9 +271,9 @@ class SchemaShot:
268
271
  )
269
272
  schema_updated = True
270
273
  elif data is not None:
271
- differences = self.differ.compare(
272
- dict(existing_schema), current_schema
273
- ).render()
274
+ merged_schema = merge_schemas(existing_schema, current_schema)
275
+
276
+ differences = self.differ.compare(dict(existing_schema), merged_schema).render()
274
277
  GLOBAL_STATS.add_uncommitted(schema_path.name, differences)
275
278
 
276
279
  # только валидируем по старой схеме
@@ -293,9 +296,9 @@ class SchemaShot:
293
296
  format_checker=FormatChecker(),
294
297
  )
295
298
  except ValidationError as e:
296
- differences = self.differ.compare(
297
- dict(existing_schema), current_schema
298
- ).render()
299
+ merged_schema = merge_schemas(existing_schema, current_schema)
300
+
301
+ differences = self.differ.compare(dict(existing_schema), merged_schema).render()
299
302
  pytest.fail(f"\n\n{differences}\n\nValidation error in `{name}`: {e.message}")
300
303
 
301
304
  return name, schema_updated