pytest-httpchain 0.1.1__tar.gz → 0.2.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.
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-httpchain
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: pytest plugin for HTTP testing using JSON files
5
5
  Keywords: testing,pytest,requests
6
6
  Author: Alexander Eresov
7
7
  Author-email: Alexander Eresov <aeresov@gmail.com>
8
+ License-Expression: MIT
8
9
  License-File: LICENSE
9
10
  Classifier: Development Status :: 5 - Production/Stable
10
11
  Classifier: Framework :: Pytest
@@ -13,11 +14,12 @@ Classifier: License :: OSI Approved :: MIT License
13
14
  Classifier: Programming Language :: Python :: 3
14
15
  Classifier: Programming Language :: Python :: 3.13
15
16
  Classifier: Topic :: Software Development :: Testing
17
+ Requires-Dist: httpx[http2]>=0.27.0
16
18
  Requires-Dist: pydantic>=2.11.7
19
+ Requires-Dist: pyrate-limiter>=3.0.0
17
20
  Requires-Dist: pytest-httpchain-jsonref
18
21
  Requires-Dist: pytest-httpchain-models
19
22
  Requires-Dist: pytest-order>=1.3.0
20
- Requires-Dist: rich>=13.7.0
21
23
  Requires-Dist: pytest-httpchain-mcp ; extra == 'mcp'
22
24
  Requires-Python: >=3.13, <4.0
23
25
  Provides-Extra: mcp
@@ -33,7 +35,7 @@ A pytest plugin for testing HTTP endpoints.
33
35
 
34
36
  ## Overview
35
37
 
36
- `pytest-httpchain` is an integration testing framework for HTTP APIs based on battle-hardened [requests](https://requests.readthedocs.io) lib.
38
+ `pytest-httpchain` is an integration testing framework for HTTP APIs based on [httpx](https://www.python-httpx.org) lib.
37
39
  It aims at helping with common HTTP API testing scenarios, where user needs to make several calls in specific order using data obtained along the way, like auth tokens or resource ids.
38
40
 
39
41
  ## Installation
@@ -60,9 +62,7 @@ The following optional dependencies are available:
60
62
 
61
63
  ### Pytest integration
62
64
 
63
- Most of pytest magic can be used: markers, fixtures, other plugins.
64
-
65
- > NOTE: parametrization is not yet implemented, therefore `parametrize` marker won't have any effect.
65
+ Most of pytest magic can be used: markers, fixtures, other plugins.
66
66
 
67
67
  ### Declarative format
68
68
 
@@ -89,6 +89,7 @@ Values from common data context also might be verified during verified/asserted.
89
89
  - to extract data from HTTP response
90
90
  - to verify HTTP response and values in common data context
91
91
  - to provide [custom authentication for requests](https://requests.readthedocs.io/en/latest/user/advanced/#custom-authentication)
92
+ - to call in substitution expressions
92
93
 
93
94
  ### JMESPath support
94
95
 
@@ -114,9 +115,13 @@ def now_utc():
114
115
 
115
116
  ```json
116
117
  {
117
- "vars": {
118
- "user_id": 1
119
- },
118
+ "substitutions": [
119
+ {
120
+ "vars": {
121
+ "user_id": 1
122
+ }
123
+ }
124
+ ],
120
125
  "stages": [
121
126
  {
122
127
  "name": "get_user",
@@ -131,7 +136,7 @@ def now_utc():
131
136
  },
132
137
  {
133
138
  "save": {
134
- "vars": {
139
+ "jmespath": {
135
140
  "user_name": "user.name"
136
141
  }
137
142
  }
@@ -186,7 +191,7 @@ Scenario we created:
186
191
  url is assembled using `user_id` variable from common data context
187
192
  we create JSON body in place using values from common data context, note that `now_utc` is converted to string in place
188
193
  HTTP PUT call with body is made
189
- we verify the call returned code 200
194
+ we verify the call returned code 200
190
195
  - **cleanup**
191
196
  finalizing call meant for graceful exit
192
197
  `always_run` parameter means this stage will be executed regardless of errors in previous stages
@@ -238,8 +243,9 @@ The MCP server provides:
238
243
 
239
244
  ## Thanks
240
245
 
241
- `pytest-httpchain` was heavily inspired by [Tavern](https://github.com/taverntesting/tavern) and [pytest-play](https://github.com/davidemoro/pytest-play).
242
- [requests](https://requests.readthedocs.io) does the comms.
243
- [Pydantic](https://docs.pydantic.dev) keeps the structure.
244
- [pytest-order](https://github.com/pytest-dev/pytest-order) powers the chaining.
245
- [pytest-datadir](https://github.com/gabrielcnr/pytest-datadir) saved me a lot of elbow grease.
246
+ `pytest-httpchain` was inspired by [Tavern](https://github.com/taverntesting/tavern) and [pytest-play](https://github.com/davidemoro/pytest-play).
247
+ [httpx](https://www.python-httpx.org) does comms.
248
+ [Pydantic](https://docs.pydantic.dev) keeps structure.
249
+ [simpleeval](https://github.com/danthedeckie/simpleeval) powers templates.
250
+ [pytest-order](https://github.com/pytest-dev/pytest-order) sorts chain.
251
+ [pytest-datadir](https://github.com/gabrielcnr/pytest-datadir) saved me a lot of elbow grease while testing.
@@ -8,7 +8,7 @@ A pytest plugin for testing HTTP endpoints.
8
8
 
9
9
  ## Overview
10
10
 
11
- `pytest-httpchain` is an integration testing framework for HTTP APIs based on battle-hardened [requests](https://requests.readthedocs.io) lib.
11
+ `pytest-httpchain` is an integration testing framework for HTTP APIs based on [httpx](https://www.python-httpx.org) lib.
12
12
  It aims at helping with common HTTP API testing scenarios, where user needs to make several calls in specific order using data obtained along the way, like auth tokens or resource ids.
13
13
 
14
14
  ## Installation
@@ -35,9 +35,7 @@ The following optional dependencies are available:
35
35
 
36
36
  ### Pytest integration
37
37
 
38
- Most of pytest magic can be used: markers, fixtures, other plugins.
39
-
40
- > NOTE: parametrization is not yet implemented, therefore `parametrize` marker won't have any effect.
38
+ Most of pytest magic can be used: markers, fixtures, other plugins.
41
39
 
42
40
  ### Declarative format
43
41
 
@@ -64,6 +62,7 @@ Values from common data context also might be verified during verified/asserted.
64
62
  - to extract data from HTTP response
65
63
  - to verify HTTP response and values in common data context
66
64
  - to provide [custom authentication for requests](https://requests.readthedocs.io/en/latest/user/advanced/#custom-authentication)
65
+ - to call in substitution expressions
67
66
 
68
67
  ### JMESPath support
69
68
 
@@ -89,9 +88,13 @@ def now_utc():
89
88
 
90
89
  ```json
91
90
  {
92
- "vars": {
93
- "user_id": 1
94
- },
91
+ "substitutions": [
92
+ {
93
+ "vars": {
94
+ "user_id": 1
95
+ }
96
+ }
97
+ ],
95
98
  "stages": [
96
99
  {
97
100
  "name": "get_user",
@@ -106,7 +109,7 @@ def now_utc():
106
109
  },
107
110
  {
108
111
  "save": {
109
- "vars": {
112
+ "jmespath": {
110
113
  "user_name": "user.name"
111
114
  }
112
115
  }
@@ -161,7 +164,7 @@ Scenario we created:
161
164
  url is assembled using `user_id` variable from common data context
162
165
  we create JSON body in place using values from common data context, note that `now_utc` is converted to string in place
163
166
  HTTP PUT call with body is made
164
- we verify the call returned code 200
167
+ we verify the call returned code 200
165
168
  - **cleanup**
166
169
  finalizing call meant for graceful exit
167
170
  `always_run` parameter means this stage will be executed regardless of errors in previous stages
@@ -213,8 +216,9 @@ The MCP server provides:
213
216
 
214
217
  ## Thanks
215
218
 
216
- `pytest-httpchain` was heavily inspired by [Tavern](https://github.com/taverntesting/tavern) and [pytest-play](https://github.com/davidemoro/pytest-play).
217
- [requests](https://requests.readthedocs.io) does the comms.
218
- [Pydantic](https://docs.pydantic.dev) keeps the structure.
219
- [pytest-order](https://github.com/pytest-dev/pytest-order) powers the chaining.
220
- [pytest-datadir](https://github.com/gabrielcnr/pytest-datadir) saved me a lot of elbow grease.
219
+ `pytest-httpchain` was inspired by [Tavern](https://github.com/taverntesting/tavern) and [pytest-play](https://github.com/davidemoro/pytest-play).
220
+ [httpx](https://www.python-httpx.org) does comms.
221
+ [Pydantic](https://docs.pydantic.dev) keeps structure.
222
+ [simpleeval](https://github.com/danthedeckie/simpleeval) powers templates.
223
+ [pytest-order](https://github.com/pytest-dev/pytest-order) sorts chain.
224
+ [pytest-datadir](https://github.com/gabrielcnr/pytest-datadir) saved me a lot of elbow grease while testing.
@@ -1,18 +1,20 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.1.1"
3
+ version = "0.2.0"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13,<4.0"
7
7
  authors = [{ name = "Alexander Eresov", email = "aeresov@gmail.com" }]
8
8
  dependencies = [
9
+ "httpx[http2]>=0.27.0",
9
10
  "pydantic>=2.11.7",
11
+ "pyrate-limiter>=3.0.0",
10
12
  "pytest-httpchain-jsonref",
11
13
  "pytest-httpchain-models",
12
14
  "pytest-order>=1.3.0",
13
- "rich>=13.7.0",
14
15
  ]
15
16
  keywords = ["testing", "pytest", "requests"]
17
+ license = "MIT"
16
18
  license-files = ["LICENSE"]
17
19
  classifiers = [
18
20
  "Development Status :: 5 - Production/Stable",
@@ -31,9 +33,10 @@ mcp = ["pytest-httpchain-mcp"]
31
33
  dev = [
32
34
  "flask-httpauth>=4.8.0",
33
35
  "http-server-mock>=1.7",
34
- "pytest-xdist>=3.8.0",
35
- "responses>=0.25.7",
36
36
  "ruff>=0.12.1",
37
+ "pytest-cov>=6.0.0",
38
+ "coverage[toml]>=7.0",
39
+ "pytest-datadir>=1.7.2",
37
40
  ]
38
41
  docs = [
39
42
  "mkdocs>=1.6.1",
@@ -43,7 +46,7 @@ docs = [
43
46
  ]
44
47
 
45
48
  [tool.uv]
46
- default-groups = ["docs"]
49
+ default-groups = ["dev", "docs"]
47
50
 
48
51
  [tool.uv.workspace]
49
52
  members = ["packages/*"]
@@ -85,10 +88,10 @@ ignore = []
85
88
  [tool.ruff.lint.isort]
86
89
  known-first-party = ["tests", "utils"]
87
90
 
88
- [tool.pytest.ini_options]
91
+ [tool.pytest]
92
+ minversion = "9.0"
89
93
  log_cli = true
90
94
  log_cli_level = "INFO"
91
- # testpaths = ["tests"]
92
95
  norecursedirs = ["examples"]
93
96
  pytester_example_dir = "tests/integration/examples"
94
97
  addopts = ["--log-disable=werkzeug", "--import-mode=importlib"]
@@ -110,3 +113,19 @@ reportMissingTypeStubs = false
110
113
  reportExplicitAny = false
111
114
  typeCheckingMode = "off"
112
115
  pythonPlatform = "Linux"
116
+
117
+ [tool.coverage.run]
118
+ source = [
119
+ "src",
120
+ "packages/pytest-httpchain-jsonref/src",
121
+ "packages/pytest-httpchain-templates/src",
122
+ "packages/pytest-httpchain-mcp/src",
123
+ "packages/pytest-httpchain-models/src",
124
+ "packages/pytest-httpchain-userfunc/src",
125
+ ]
126
+ branch = true
127
+
128
+ [tool.coverage.report]
129
+ precision = 2
130
+ show_missing = true
131
+ skip_covered = false
@@ -0,0 +1,23 @@
1
+ """pytest-httpchain: Declarative HTTP API integration testing.
2
+
3
+ This pytest plugin enables declarative HTTP API integration testing using JSON files.
4
+ Test scenarios are defined with $ref support, template expressions ({{ expr }}),
5
+ and multi-stage request chaining.
6
+
7
+ Example test file (test_api.http.json):
8
+ {
9
+ "description": "API integration test",
10
+ "stages": [
11
+ {
12
+ "name": "Get user",
13
+ "request": {
14
+ "method": "GET",
15
+ "url": "https://api.example.com/users/1"
16
+ },
17
+ "response": [
18
+ {"verify": {"status": 200}}
19
+ ]
20
+ }
21
+ ]
22
+ }
23
+ """