pytest-httpchain 0.18.1__tar.gz → 0.20.0__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 (56) hide show
  1. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/PKG-INFO +7 -3
  2. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/README.md +5 -1
  3. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/pyproject.toml +7 -5
  4. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/pyproject.toml.orig +20 -5
  5. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/__init__.py +4 -2
  6. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/carrier.py +480 -81
  7. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/cli.py +116 -9
  8. pytest_httpchain-0.20.0/src/pytest_httpchain/connections.py +931 -0
  9. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/constants.py +6 -3
  10. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/dataflow.py +72 -7
  11. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/factory.py +3 -3
  12. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/importers/builder.py +48 -1
  13. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/models/__init__.py +14 -1
  14. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/models/entities.py +202 -13
  15. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/models/types.py +227 -1
  16. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/plugin.py +37 -5
  17. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/redaction.py +135 -6
  18. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/report_formatter.py +143 -1
  19. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/request_builder.py +3 -1
  20. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/response_steps.py +175 -30
  21. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/scoping.py +229 -3
  22. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/templates/functions.py +8 -0
  23. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/userfunc.py +32 -2
  24. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/utils.py +18 -0
  25. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/deep.py +114 -7
  26. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/diagnostics.py +13 -0
  27. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/loader.py +32 -8
  28. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/semantic.py +422 -59
  29. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/LICENSE +0 -0
  30. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/body_schema.py +0 -0
  31. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/errors.py +0 -0
  32. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/har_writer.py +0 -0
  33. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/importers/__init__.py +0 -0
  34. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/importers/curl.py +0 -0
  35. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/importers/har.py +0 -0
  36. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/__init__.py +0 -0
  37. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/equality.py +0 -0
  38. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/exceptions.py +0 -0
  39. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/jsonc.py +0 -0
  40. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/loader.py +0 -0
  41. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/plumbing/__init__.py +0 -0
  42. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/plumbing/circular.py +0 -0
  43. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/plumbing/path.py +0 -0
  44. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/jsonref/plumbing/reference.py +0 -0
  45. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/parallel_stats.py +0 -0
  46. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/py.typed +0 -0
  47. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/schema.py +0 -0
  48. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/templates/__init__.py +0 -0
  49. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/templates/exceptions.py +0 -0
  50. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/templates/expressions.py +0 -0
  51. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/templates/substitution.py +0 -0
  52. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/__init__.py +0 -0
  53. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/discovery.py +0 -0
  54. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/validation/validate.py +0 -0
  55. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/warnings.py +0 -0
  56. {pytest_httpchain-0.18.1 → pytest_httpchain-0.20.0}/src/pytest_httpchain/wire_codec.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-httpchain
3
- Version: 0.18.1
3
+ Version: 0.20.0
4
4
  Summary: pytest plugin for HTTP testing using JSON files
5
5
  Keywords: testing,pytest,httpx,http,api,integration-testing
6
6
  Author: Alexander Eresov
@@ -17,7 +17,7 @@ Classifier: Topic :: Software Development :: Testing
17
17
  Classifier: Typing :: Typed
18
18
  Requires-Dist: attrs>=22.2.0
19
19
  Requires-Dist: deepmerge>=2.0
20
- Requires-Dist: graphql-core>=3.0.0
20
+ Requires-Dist: graphql-core>=3.2.10
21
21
  Requires-Dist: httpx[http2]>=0.28.0
22
22
  Requires-Dist: iniconfig>=1.0.1
23
23
  Requires-Dist: jmespath>=1.0.0
@@ -100,6 +100,10 @@ JSON, MessagePack, form, XML, text, base64, a binary file and GraphQL, and multi
100
100
  - **User functions** — Call Python functions for custom extraction, verification, or [authentication](https://www.python-httpx.org/advanced/authentication/#custom-authentication-schemes)
101
101
  - **Failure reports** — A failing verify step lists every check that failed, not only the first, and the report gives the request as a ready-to-run `curl` command beside the request and response it shows
102
102
 
103
+ ### Socket protocols via adapters
104
+
105
+ Not every service a test talks to speaks HTTP. A `connection` stage drives a long-lived connection through an adapter, a small Python class you write that connects, sends one message and decodes the next: `"connection": {"name": "device", "send": {"op": "ping"}, "expect": {"match": {"op": "pong"}, "timeout": 2}}`. Every message received is queued for the stages that wait for it; `expect` takes the one that matches, asserts that none arrives (`absent`) or that the other side hangs up (`closed`), and the same `verify` and `save` steps an HTTP stage uses check it. HTTP and connection stages mix in one chain, sharing what they save. See [Connections](https://aeresov.github.io/pytest-httpchain/usage/connections/).
106
+
103
107
  ### Scenario-wide client settings
104
108
 
105
109
  A scenario's `client` block sets up the HTTP client all its stages share, once: a base URL their relative URLs are appended to, headers and query parameters sent with every request, timeout, redirects, proxy, HTTP/2 and connection pool. A stage overrides what it needs.
@@ -226,7 +230,7 @@ pip install 'git+https://github.com/aeresov/pytest-httpchain@main'
226
230
  You can limit the depth of relative path traversal using the `httpchain_ref_parent_traversal_depth` ini option, default value is **3**.
227
231
  - Template expressions support list/dict comprehensions. You can limit the maximum comprehension length using the `httpchain_max_comprehension_length` ini option, default value is **50000**.
228
232
  - Parallel stage iterations (repeat/foreach) have a safety limit configurable via the `httpchain_max_parallel_iterations` ini option, default value is **10000**.
229
- - A failing stage's report prints the values of credential headers and query parameters as `[REDACTED]`, keeping their names (and cookie names). The lists are set by the `httpchain_redact_headers` ini option, default **Authorization Proxy-Authorization Cookie Set-Cookie X-API-Key API-Key X-Auth-Token**, and `httpchain_redact_query_params`, default **access_token refresh_token id_token api_key apikey client_secret password token**; an empty value disables one. Request and response bodies, and DEBUG logs, are not redacted. See [Secrets in reports](https://aeresov.github.io/pytest-httpchain/getting-started/#secrets-in-reports).
233
+ - A failing stage's report prints the values of credential headers and query parameters as `[REDACTED]`, keeping their names (and cookie names). The lists are set by the `httpchain_redact_headers` ini option, default **Authorization Proxy-Authorization Cookie Set-Cookie X-API-Key API-Key X-Auth-Token**, and `httpchain_redact_query_params`, default **access_token refresh_token id_token api_key apikey client_secret password token**; an empty value disables one. A connection stage's messages are redacted by key, at any depth, by `httpchain_redact_message_keys`, default both lists lowercased. Request and response bodies, and DEBUG logs, are not redacted. See [Secrets in reports](https://aeresov.github.io/pytest-httpchain/getting-started/#secrets-in-reports).
230
234
 
231
235
  ### HAR export
232
236
 
@@ -62,6 +62,10 @@ JSON, MessagePack, form, XML, text, base64, a binary file and GraphQL, and multi
62
62
  - **User functions** — Call Python functions for custom extraction, verification, or [authentication](https://www.python-httpx.org/advanced/authentication/#custom-authentication-schemes)
63
63
  - **Failure reports** — A failing verify step lists every check that failed, not only the first, and the report gives the request as a ready-to-run `curl` command beside the request and response it shows
64
64
 
65
+ ### Socket protocols via adapters
66
+
67
+ Not every service a test talks to speaks HTTP. A `connection` stage drives a long-lived connection through an adapter, a small Python class you write that connects, sends one message and decodes the next: `"connection": {"name": "device", "send": {"op": "ping"}, "expect": {"match": {"op": "pong"}, "timeout": 2}}`. Every message received is queued for the stages that wait for it; `expect` takes the one that matches, asserts that none arrives (`absent`) or that the other side hangs up (`closed`), and the same `verify` and `save` steps an HTTP stage uses check it. HTTP and connection stages mix in one chain, sharing what they save. See [Connections](https://aeresov.github.io/pytest-httpchain/usage/connections/).
68
+
65
69
  ### Scenario-wide client settings
66
70
 
67
71
  A scenario's `client` block sets up the HTTP client all its stages share, once: a base URL their relative URLs are appended to, headers and query parameters sent with every request, timeout, redirects, proxy, HTTP/2 and connection pool. A stage overrides what it needs.
@@ -188,7 +192,7 @@ pip install 'git+https://github.com/aeresov/pytest-httpchain@main'
188
192
  You can limit the depth of relative path traversal using the `httpchain_ref_parent_traversal_depth` ini option, default value is **3**.
189
193
  - Template expressions support list/dict comprehensions. You can limit the maximum comprehension length using the `httpchain_max_comprehension_length` ini option, default value is **50000**.
190
194
  - Parallel stage iterations (repeat/foreach) have a safety limit configurable via the `httpchain_max_parallel_iterations` ini option, default value is **10000**.
191
- - A failing stage's report prints the values of credential headers and query parameters as `[REDACTED]`, keeping their names (and cookie names). The lists are set by the `httpchain_redact_headers` ini option, default **Authorization Proxy-Authorization Cookie Set-Cookie X-API-Key API-Key X-Auth-Token**, and `httpchain_redact_query_params`, default **access_token refresh_token id_token api_key apikey client_secret password token**; an empty value disables one. Request and response bodies, and DEBUG logs, are not redacted. See [Secrets in reports](https://aeresov.github.io/pytest-httpchain/getting-started/#secrets-in-reports).
195
+ - A failing stage's report prints the values of credential headers and query parameters as `[REDACTED]`, keeping their names (and cookie names). The lists are set by the `httpchain_redact_headers` ini option, default **Authorization Proxy-Authorization Cookie Set-Cookie X-API-Key API-Key X-Auth-Token**, and `httpchain_redact_query_params`, default **access_token refresh_token id_token api_key apikey client_secret password token**; an empty value disables one. A connection stage's messages are redacted by key, at any depth, by `httpchain_redact_message_keys`, default both lists lowercased. Request and response bodies, and DEBUG logs, are not redacted. See [Secrets in reports](https://aeresov.github.io/pytest-httpchain/getting-started/#secrets-in-reports).
192
196
 
193
197
  ### HAR export
194
198
 
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.18.1"
3
+ version = "0.20.0"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
8
8
  "attrs>=22.2.0",
9
9
  "deepmerge>=2.0",
10
- "graphql-core>=3.0.0",
10
+ "graphql-core>=3.2.10",
11
11
  "httpx[http2]>=0.28.0",
12
12
  "iniconfig>=1.0.1",
13
13
  "jmespath>=1.0.0",
@@ -63,7 +63,7 @@ dev = [
63
63
  "flask-httpauth>=4.8.0",
64
64
  "import-linter>=2.0",
65
65
  "ruff>=0.12.1",
66
- "ty>=0.0.84",
66
+ "ty>=0.0.100",
67
67
  "coverage[toml]>=7.10",
68
68
  "pytest-datadir>=1.7.2",
69
69
  "pytest-order>=1.3.0",
@@ -125,7 +125,8 @@ include = ["tests/**"]
125
125
  [tool.ty.overrides.rules]
126
126
  invalid-argument-type = "ignore"
127
127
  unknown-argument = "ignore"
128
- unresolved-attribute = "ignore"
128
+ missing-attribute = "ignore"
129
+ missing-union-attribute = "ignore"
129
130
  not-subscriptable = "ignore"
130
131
  missing-argument = "ignore"
131
132
 
@@ -173,6 +174,7 @@ layers = [
173
174
  "factory",
174
175
  "carrier : dataflow : schema : importers",
175
176
  "validation : har_writer : report_formatter : request_builder : response_steps : parallel_stats",
177
+ "connections",
176
178
  "body_schema",
177
179
  "scoping",
178
180
  "utils : redaction",
@@ -190,5 +192,5 @@ source_modules = ["pytest_httpchain.models"]
190
192
  forbidden_modules = ["pytest_httpchain.jsonref"]
191
193
 
192
194
  [build-system]
193
- requires = ["uv_build>=0.12,<0.13"]
195
+ requires = ["uv_build>=0.12,<0.14"]
194
196
  build-backend = "uv_build"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.18.1"
3
+ version = "0.20.0"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -10,7 +10,13 @@ dependencies = [
10
10
  # (body_schema): the floor jsonschema 4.18.0 itself requires.
11
11
  "attrs>=22.2.0",
12
12
  "deepmerge>=2.0",
13
- "graphql-core>=3.0.0",
13
+ # 3.2.10 is the first release that parses a description on an operation,
14
+ # a fragment or a variable, as every final release after it does: below
15
+ # it, a query holding one loads or not by the version installed. (The
16
+ # 3.3.0 pre-releases before 3.3.0a13, which `>=` admits once pre-releases
17
+ # are allowed, do not.) Not 3.3: graphene, graphql-relay and sgqlc require
18
+ # a graphql-core below it.
19
+ "graphql-core>=3.2.10",
14
20
  # 0.28.0 is the first release that takes a socks5h:// proxy, which
15
21
  # client.proxy accepts. (0.27.0 also percent-encoded a `\` in a URL path,
16
22
  # `/a%5Cb`, so a URL the plugin sends as written did not reach the server
@@ -65,7 +71,12 @@ dev = [
65
71
  "flask-httpauth>=4.8.0",
66
72
  "import-linter>=2.0",
67
73
  "ruff>=0.12.1",
68
- "ty>=0.0.84",
74
+ # 0.0.100 renamed the rules that [tool.ty.overrides.rules] and the
75
+ # `ty: ignore[...]` comments in src/ name: unresolved-attribute became
76
+ # missing-attribute (its union case split out as missing-union-attribute)
77
+ # and invalid-{method,attribute}-override became incompatible-...-override.
78
+ # An older ty does not know the new names, so `ty check` fails on it.
79
+ "ty>=0.0.100",
69
80
  "coverage[toml]>=7.10", # `patch = ["subprocess"]` needs 7.10
70
81
 
71
82
  "pytest-datadir>=1.7.2",
@@ -88,7 +99,7 @@ docs = [
88
99
  default-groups = ["dev", "docs"]
89
100
 
90
101
  [build-system]
91
- requires = ["uv_build>=0.12,<0.13"]
102
+ requires = ["uv_build>=0.12,<0.14"]
92
103
  build-backend = "uv_build"
93
104
 
94
105
  [tool.uv.build-backend]
@@ -144,7 +155,8 @@ include = ["tests/**"]
144
155
  [tool.ty.overrides.rules]
145
156
  invalid-argument-type = "ignore"
146
157
  unknown-argument = "ignore"
147
- unresolved-attribute = "ignore"
158
+ missing-attribute = "ignore"
159
+ missing-union-attribute = "ignore"
148
160
  not-subscriptable = "ignore"
149
161
  missing-argument = "ignore"
150
162
 
@@ -218,6 +230,9 @@ layers = [
218
230
  # a lower layer, the domain packages included, may import it.
219
231
  "carrier : dataflow : schema : importers",
220
232
  "validation : har_writer : report_formatter : request_builder : response_steps : parallel_stats",
233
+ # connections is the connection stages' sessions and readers, below
234
+ # response_steps, which judges a message: the carrier injects the match.
235
+ "connections",
221
236
  "body_schema",
222
237
  # scoping reads stage marks with utils.make_marker (scoping.SkipCause).
223
238
  "scoping",
@@ -2,9 +2,11 @@
2
2
 
3
3
  Test scenarios are JSON files (``test_<name>.http.json``, or ``.http.jsonc``;
4
4
  comments and trailing commas allowed in either) with ``$ref`` support,
5
- ``{{ expr }}`` templates, and multi-stage request chaining.
5
+ ``{{ expr }}`` templates, and multi-stage request chaining. A connection
6
+ stage talks over a protocol adapter instead (`ProtocolAdapter`).
6
7
  """
7
8
 
9
+ from pytest_httpchain.connections import ProtocolAdapter
8
10
  from pytest_httpchain.warnings import ScenarioValidationWarning
9
11
 
10
- __all__ = ["ScenarioValidationWarning"]
12
+ __all__ = ["ProtocolAdapter", "ScenarioValidationWarning"]