pytest-api-core 1.0.1__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.
@@ -0,0 +1,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-api-core
3
+ Version: 1.0.1
4
+ Summary: Pytest API automation framework with custom HTML reporting, reusable fixtures, and fluent assertions
5
+ Author: QA Platform Team
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Subodh Singh
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/your-org/pytest-api-core-framework
29
+ Project-URL: Documentation, https://your-org.artifactory.com/docs/pytest-api-core
30
+ Keywords: pytest,api,testing,automation,html-report
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Framework :: Pytest
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Topic :: Software Development :: Testing
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Operating System :: OS Independent
41
+ Requires-Python: >=3.9
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: pytest>=7.4
45
+ Requires-Dist: requests>=2.31
46
+ Requires-Dist: Jinja2>=3.1
47
+ Requires-Dist: urllib3>=2.0
48
+ Requires-Dist: jsonschema>=4.20
49
+ Provides-Extra: dotenv
50
+ Requires-Dist: python-dotenv>=1.0; extra == "dotenv"
51
+ Provides-Extra: dev
52
+ Requires-Dist: pytest-mock>=3.12; extra == "dev"
53
+ Requires-Dist: responses>=0.25; extra == "dev"
54
+ Requires-Dist: black>=24.0; extra == "dev"
55
+ Requires-Dist: isort>=5.13; extra == "dev"
56
+ Requires-Dist: mypy>=1.8; extra == "dev"
57
+ Requires-Dist: twine>=5.0; extra == "dev"
58
+ Requires-Dist: build>=1.0; extra == "dev"
59
+ Dynamic: license-file
60
+
61
+ # pytest-api-core
62
+
63
+ > A reusable pytest API automation framework with fluent assertions, built-in auth strategies, environment-aware configuration, and a beautiful custom HTML report — packaged for Artifactory distribution.
64
+
65
+ ## Features
66
+
67
+ - **`APIClient`** — `requests.Session` wrapper with retry, timeout, and structured logging
68
+ - **Fluent response assertions** — `assert_that(response).status_is(200).json_path("$.id").equals(1)`
69
+ - **Auth strategies** — Bearer token, Basic, API Key (header/query), OAuth2 client credentials
70
+ - **Environment config** — Python `settings.py` classes + `.env` file + `ENV_VAR` overrides via `api_config` fixture
71
+ - **Custom HTML report** — self-contained report with charts, filterable table, captured logs, and request/response details
72
+ - **Auto-registered pytest fixtures** — zero boilerplate in consuming projects
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ ### From private PyPI
79
+
80
+ ```bash
81
+ pip install pytest-api-core \
82
+ --index-url https://pypi.example.com/simple/
83
+ ```
84
+
85
+ With `.env` support (optional but recommended):
86
+
87
+ ```bash
88
+ pip install "pytest-api-core[dotenv]"
89
+ ```
90
+
91
+ Or add to `requirements.txt` / `pyproject.toml`:
92
+
93
+ ```
94
+ pytest-api-core==1.0.0
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Quick Start
100
+
101
+ ### 1. Create environment settings
102
+
103
+ ```python
104
+ # config/settings.py
105
+ import os
106
+ from pytest_api_core.config.base_settings import BaseSettings
107
+
108
+ class DevSettings(BaseSettings):
109
+ base_url = "https://api.dev.example.com"
110
+ timeout = 30
111
+ verify_ssl = True
112
+ headers = {"Accept": "application/json", "Content-Type": "application/json"}
113
+
114
+ class StagingSettings(DevSettings):
115
+ base_url = os.environ.get("API_BASE_URL", "https://api.staging.example.com")
116
+ timeout = 60
117
+
118
+ ENVIRONMENTS = {
119
+ "dev": DevSettings,
120
+ "staging": StagingSettings,
121
+ }
122
+ ```
123
+
124
+ ### 2. Store secrets in `.env` (never commit this file)
125
+
126
+ ```ini
127
+ # .env
128
+ BEARER_TOKEN=eyJhbGciOiJIUzI1NiIs...
129
+ API_KEY=super-secret-key
130
+ ```
131
+
132
+ ### 3. Configure pytest.ini
133
+
134
+ ```ini
135
+ [pytest]
136
+
137
+ # ── Framework ────────────────────────────────────────────────────────────────
138
+ api_env = dev
139
+ api_settings_module = config.settings
140
+ api_dotenv_file = .env
141
+
142
+ # ── Report ───────────────────────────────────────────────────────────────────
143
+ addopts = --api-html-report=reports/{env}/report_{timestamp}.html -v
144
+ api_html_theme = dark # or "light"
145
+ api_html_title = API Test Report # browser tab title
146
+ api_html_header = API Test Report # page header text
147
+
148
+ # ── Logging ──────────────────────────────────────────────────────────────────
149
+ api_log_level = INFO
150
+ log_cli = true
151
+ log_cli_level = INFO
152
+ log_cli_format = %(asctime)s [%(levelname)-8s] %(name)s: %(message)s
153
+ log_cli_date_format = %H:%M:%S
154
+ ```
155
+
156
+ ### 4. Write tests
157
+
158
+ ```python
159
+ # tests/test_posts.py
160
+ from pytest_api_core.assertions import assert_that
161
+
162
+ def test_get_post(api_client):
163
+ response = api_client.get("/posts/1")
164
+ assert_that(response).status_is(200).json_path("$.id").equals(1)
165
+
166
+ def test_create_post(api_client):
167
+ payload = {"title": "foo", "body": "bar", "userId": 1}
168
+ response = api_client.post("/posts", json=payload)
169
+ assert_that(response).status_is(201).has_key("id")
170
+ ```
171
+
172
+ ### 5. Run with HTML report
173
+
174
+ ```bash
175
+ pytest tests/ --api-env=staging
176
+ ```
177
+
178
+ The report is written to `reports/staging/report_<timestamp>.html`.
179
+
180
+ ---
181
+
182
+ ## Configuration
183
+
184
+ ### Resolution order (highest → lowest priority)
185
+
186
+ | Priority | Source |
187
+ |---|---|
188
+ | 1 | Shell / CI environment variables (`API_BASE_URL`, `API_TOKEN`, …) |
189
+ | 2 | `--api-base-url` CLI flag |
190
+ | 3 | `ENVIRONMENTS[env]` class in `settings_module` |
191
+ | 4 | Built-in defaults (`http://localhost`, timeout 30 s, …) |
192
+
193
+ ### pytest.ini options
194
+
195
+ | Option | Description | Default |
196
+ |---|---|---|
197
+ | `api_env` | Active environment name | `dev` |
198
+ | `api_settings_module` | Dotted path to settings module | — |
199
+ | `api_dotenv_file` | Path to `.env` file | `.env` |
200
+ | `api_log_level` | Log level for framework internals | `WARNING` |
201
+ | `api_html_report` | Output path for HTML report (supports `{env}`, `{timestamp}`) | — |
202
+ | `api_html_theme` | Report theme: `light` or `dark` | `dark` |
203
+ | `api_html_title` | Browser tab title text | `API Test Report` |
204
+ | `api_html_header` | Page header text | `API Test Report` |
205
+
206
+ ### CLI flags
207
+
208
+ | Flag | Description |
209
+ |---|---|
210
+ | `--api-env` | Override active environment |
211
+ | `--api-base-url` | Override `base_url` |
212
+ | `--api-log-level` | Override framework log level |
213
+ | `--api-html-report` | Override HTML report path |
214
+
215
+ ### Environment variables
216
+
217
+ | Variable | Purpose |
218
+ |---|---|
219
+ | `API_BASE_URL` | Override `base_url` |
220
+ | `API_TOKEN` | Inject Bearer token (auto-applied by `api_client`) |
221
+ | `API_ENV` | Select environment |
222
+ | `API_TIMEOUT` | Override request timeout |
223
+ | `API_VERIFY_SSL` | Override SSL verification |
224
+
225
+ ---
226
+
227
+ ## Fixtures
228
+
229
+ | Fixture | Scope | Description |
230
+ |---|---|---|
231
+ | `api_config` | session | Resolved config dict for the active env |
232
+ | `api_client` | session | Configured `APIClient` instance |
233
+ | `api_bearer_auth` | function | `BearerAuth` built from `API_TOKEN` env var |
234
+ | `api_basic_auth` | function | `BasicAuth` built from `API_USERNAME` / `API_PASSWORD` |
235
+ | `api_key_auth` | function | `APIKeyAuth` built from `API_KEY_NAME` / `API_KEY_VALUE` |
236
+
237
+ ### Overriding `api_client` per project
238
+
239
+ ```python
240
+ # tests/conftest.py
241
+ import pytest
242
+ from pytest_api_core.auth.auth_handlers import BearerAuth
243
+ from pytest_api_core.client.api_client import APIClient
244
+ from pytest_api_core.config.env_loader import get_env
245
+
246
+ @pytest.fixture(scope="session")
247
+ def api_client(api_config):
248
+ token = get_env("BEARER_TOKEN", required=True)
249
+ client = APIClient(
250
+ base_url=api_config["base_url"],
251
+ auth=BearerAuth(token),
252
+ timeout=api_config.get("timeout", 30),
253
+ verify_ssl=api_config.get("verify_ssl", True),
254
+ default_headers=api_config.get("headers"),
255
+ )
256
+ yield client
257
+ client.close()
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Publishing
263
+
264
+ ### Via GitHub Actions (Recommended)
265
+
266
+ Use the **Publish to Public PyPI** workflow for automated releases:
267
+
268
+ 1. Go to **Actions** → **Publish to Public PyPI**
269
+ 2. Click **Run workflow**
270
+ 3. Enter version (e.g., `1.0.1`) and enable/disable tests
271
+ 4. Workflow will build, test, and publish to PyPI
272
+
273
+ See [docs/PUBLISHING.md](docs/PUBLISHING.md) for detailed setup instructions.
274
+
275
+ ### Manual Publishing
276
+
277
+ ```bash
278
+ # Build
279
+ python -m build
280
+
281
+ # Upload to PyPI
282
+ twine upload dist/*
283
+
284
+ # Or upload to private registry
285
+ twine upload \
286
+ --repository-url https://pypi.example.com \
287
+ -u <user> -p <token> \
288
+ dist/*
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Project Layout
294
+
295
+ ```
296
+ src/
297
+ └── pytest_api_core/
298
+ ├── plugin.py # pytest entry-point
299
+ ├── client/ # HTTP client + response wrapper
300
+ ├── auth/ # Auth strategy classes
301
+ ├── config/ # Config manager, BaseSettings, env_loader
302
+ ├── fixtures/ # Auto-registered pytest fixtures
303
+ ├── assertions/ # Fluent response assertion API
304
+ └── reporters/ # Custom HTML report plugin
305
+ config/
306
+ └── settings.py # Project environment settings (not shipped in wheel)
307
+ tests/ # Package self-tests
308
+ ```
309
+
310
+ ---
311
+
312
+ ## License
313
+
314
+ See [LICENSE](LICENSE).
@@ -0,0 +1,24 @@
1
+ pytest_api_core/__init__.py,sha256=k1sLp0q5McZ-xx46tqz2qHfZOAQoFnuacFLSOkQa6ng,606
2
+ pytest_api_core/plugin.py,sha256=ztZUdEnLZAqjooth7I3-L_IbFkjIMw38XAw0LmlVRrg,4720
3
+ pytest_api_core/assertions/__init__.py,sha256=nTgAKLFR-po-akWbWUPhugs_6vC7joZ1KsKs1yCRCPo,140
4
+ pytest_api_core/assertions/response_assertions.py,sha256=ypDrTFYZQPz7-8nmntbJvxbh-LnWU2teEBFNFHDyvXE,13735
5
+ pytest_api_core/auth/__init__.py,sha256=2MZWga1KltncKtWS6BjFWZNlWxW-ZQLyNNMBptir1DA,207
6
+ pytest_api_core/auth/auth_handlers.py,sha256=yZI5SiAiMBURPklGztCiwDcIWgYq-tTI2Wsk2s_pogI,4961
7
+ pytest_api_core/client/__init__.py,sha256=BzEGJ-vtVIBxtbPKo51GZiNP4ta4VerHNh1vY7tTzGc,156
8
+ pytest_api_core/client/api_client.py,sha256=8d-ft6BiljouxJFvO5ZbXFfrpCD4V9eEuO2AwCWmZDY,5866
9
+ pytest_api_core/client/api_response.py,sha256=SEfjCelE8x2TCvRCh-1fLhBhkNRL0doCxKQfoWsSi7c,3259
10
+ pytest_api_core/config/__init__.py,sha256=AB-ZPcczHdj2QXfNVegJI6zpvrPwB12tk1p6ZKVqJBQ,93
11
+ pytest_api_core/config/base_settings.py,sha256=kSZfpM7Qb_VdxoQt0iFx9aWoLyqwYaQ-yBn_EVUHUsM,1588
12
+ pytest_api_core/config/config_manager.py,sha256=C4l9zYCbqYQkR8fi52UJRkDSag1Npi5Siw40hkRj-MA,4943
13
+ pytest_api_core/config/env_loader.py,sha256=ZdqvYlheLVeMlUxkPjsneB_J-p0-53KTg4JnJCCKSDs,3624
14
+ pytest_api_core/fixtures/__init__.py,sha256=pym_n1dGNyMjsMJ8pBvpRhL6NO1AOxAz9GCAk7buPo4,238
15
+ pytest_api_core/fixtures/api_fixtures.py,sha256=hWHaF1UAb05LtOLnBPOcx9X8RTYOFldjiwke-r0YzHE,4533
16
+ pytest_api_core/reporters/__init__.py,sha256=x8Nz9l_XVJ6UnhiWagpGiYpavRn1rT_19URxmJx51WA,93
17
+ pytest_api_core/reporters/html_reporter.py,sha256=4t_Ct9pgzpdnmyuIVz5J7i9Afs3KshHrqkO2UfsBpwo,9135
18
+ pytest_api_core/reporters/templates/report.html,sha256=FttRFPEyu0QkGWBCz7X6C_voavCqiI-fhwL55TmLeJw,23471
19
+ pytest_api_core-1.0.1.dist-info/licenses/LICENSE,sha256=KX3V5BBuPfOzHocmg7neh05ynY2-SuUIQcKTUWY_YRA,1069
20
+ pytest_api_core-1.0.1.dist-info/METADATA,sha256=lLd9idA_F_vZp0GDa8R5BUq7Ioo3-IfLq_atFumzWn8,10411
21
+ pytest_api_core-1.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
22
+ pytest_api_core-1.0.1.dist-info/entry_points.txt,sha256=zLSsWALblfMzUMTQ9XNtWm1DadnIEXZIGdcaRDXzxYk,52
23
+ pytest_api_core-1.0.1.dist-info/top_level.txt,sha256=1Oc_pFT9Ma9pS94FlcPYoAp6op8BJBVccq2CVXybApo,16
24
+ pytest_api_core-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [pytest11]
2
+ pytest-api-core = pytest_api_core.plugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Subodh Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ pytest_api_core