schemathesis 4.0.21__py3-none-any.whl → 4.0.23__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.
schemathesis/hooks.py CHANGED
@@ -395,7 +395,7 @@ def hook(hook: str | Callable) -> Callable:
395
395
  return query and "user_id" in query
396
396
 
397
397
  @schemathesis.hook
398
- def before_call(ctx, case):
398
+ def before_call(ctx, case, **kwargs):
399
399
  \"\"\"Modify headers before sending each request\"\"\"
400
400
  if case.headers is None:
401
401
  case.headers = {}
@@ -301,6 +301,8 @@ def generate_parameter(
301
301
  if value == explicit:
302
302
  # When we pass `explicit`, then its parts are excluded from generation of the final value
303
303
  # If the final value is the same, then other parameters were generated at all
304
+ if value is not None and location == "path":
305
+ value = quote_all(value)
304
306
  used_generator = None
305
307
  return ValueContainer(value=value, location=location, generator=used_generator)
306
308
 
@@ -408,8 +408,11 @@ def ensure_resource_availability(ctx: CheckContext, response: Response, case: Ca
408
408
  if not isinstance(case.operation.schema, BaseOpenAPISchema) or is_unexpected_http_status_case(case):
409
409
  return True
410
410
 
411
- # First, check if this is a 4XX response
412
- if not (400 <= response.status_code < 500):
411
+ # Only check for 404 (Not Found) responses - other 4XX are not resource availability issues
412
+ # 422 / 400: Validation errors (bad request data)
413
+ # 401 / 403: Auth issues (expired tokens, permissions)
414
+ # 409: Conflict errors
415
+ if response.status_code != 404:
413
416
  return None
414
417
 
415
418
  parent = ctx._find_parent(case_id=case.id)
@@ -51,6 +51,20 @@ class BodyExample:
51
51
  Example = Union[ParameterExample, BodyExample]
52
52
 
53
53
 
54
+ def merge_kwargs(left: dict[str, Any], right: dict[str, Any]) -> dict[str, Any]:
55
+ mergeable_keys = {"path_parameters", "headers", "cookies", "query"}
56
+
57
+ for key, value in right.items():
58
+ if key in mergeable_keys and key in left:
59
+ if isinstance(left[key], dict) and isinstance(value, dict):
60
+ # kwargs takes precedence
61
+ left[key] = {**left[key], **value}
62
+ continue
63
+ left[key] = value
64
+
65
+ return left
66
+
67
+
54
68
  def get_strategies_from_examples(
55
69
  operation: APIOperation[OpenAPIParameter], **kwargs: Any
56
70
  ) -> list[SearchStrategy[Case]]:
@@ -72,7 +86,7 @@ def get_strategies_from_examples(
72
86
  # Add examples from parameter's schemas
73
87
  examples.extend(extract_from_schemas(operation))
74
88
  return [
75
- openapi_cases(operation=operation, **{**parameters, **kwargs, "phase": TestPhase.EXAMPLES}).map(
89
+ openapi_cases(operation=operation, phase=TestPhase.EXAMPLES, **merge_kwargs(parameters, kwargs)).map(
76
90
  serialize_components
77
91
  )
78
92
  for parameters in produce_combinations(examples)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: schemathesis
3
- Version: 4.0.21
3
+ Version: 4.0.23
4
4
  Summary: Property-based testing framework for Open API and GraphQL based apps
5
5
  Project-URL: Documentation, https://schemathesis.readthedocs.io/en/stable/
6
6
  Project-URL: Changelog, https://github.com/schemathesis/schemathesis/blob/master/CHANGELOG.md
@@ -3,7 +3,7 @@ schemathesis/auths.py,sha256=JdEwPRS9WKmPcxzGXYYz9pjlIUMQYCfif7ZJU0Kde-I,16400
3
3
  schemathesis/checks.py,sha256=GTdejjXDooAOuq66nvCK3i-AMPBuU-_-aNeSeL9JIlc,6561
4
4
  schemathesis/errors.py,sha256=T8nobEi5tQX_SkwaYb8JFoIlF9F_vOQVprZ8EVPAhjA,931
5
5
  schemathesis/filters.py,sha256=OEub50Ob5sf0Tn3iTeuIaxSMtepF7KVoiEM9wtt5GGA,13433
6
- schemathesis/hooks.py,sha256=L1o9IQz0_mY59gs3WGHGSCnGHjF6WWEZZuwJaHcVG1o,13922
6
+ schemathesis/hooks.py,sha256=OEnZw5lKSweNdycBRIOsn085rTB-L-iJAjj4ClldkU4,13932
7
7
  schemathesis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  schemathesis/schemas.py,sha256=glaIjN7JO1mdOCs5_HUFjLWQ-89z8NFBUIuc5p8cLAU,28386
9
9
  schemathesis/cli/__init__.py,sha256=U9gjzWWpiFhaqevPjZbwyTNjABdpvXETI4HgwdGKnvs,877
@@ -123,12 +123,12 @@ schemathesis/specs/graphql/schemas.py,sha256=ezkqgMwx37tMWlhy_I0ahDF1Q44emDSJkyj
123
123
  schemathesis/specs/graphql/validation.py,sha256=-W1Noc1MQmTb4RX-gNXMeU2qkgso4mzVfHxtdLkCPKM,1422
124
124
  schemathesis/specs/openapi/__init__.py,sha256=C5HOsfuDJGq_3mv8CRBvRvb0Diy1p0BFdqyEXMS-loE,238
125
125
  schemathesis/specs/openapi/_cache.py,sha256=HpglmETmZU0RCHxp3DO_sg5_B_nzi54Zuw9vGzzYCxY,4295
126
- schemathesis/specs/openapi/_hypothesis.py,sha256=H-4pzT7dECY-AcDGhebKdTSELhGOdyA1WCbZQSMZY3E,22309
127
- schemathesis/specs/openapi/checks.py,sha256=t3ZIyzRPd_KnJzdp57Y_9CZLYC98NAqsE3dgNfuCOBA,29971
126
+ schemathesis/specs/openapi/_hypothesis.py,sha256=shKwQPWupBSZgZ1m35HjSJi0HX0Yv5wqjdkYWA_EE7U,22399
127
+ schemathesis/specs/openapi/checks.py,sha256=1_YIcGqZ2xSN_1Ob_CIt_HfARSodMCCYNX4SQXx03-c,30150
128
128
  schemathesis/specs/openapi/constants.py,sha256=JqM_FHOenqS_MuUE9sxVQ8Hnw0DNM8cnKDwCwPLhID4,783
129
129
  schemathesis/specs/openapi/converter.py,sha256=LkpCCAxZzET4Qa_3YStSNuhGlsm5G6TVwpxYu6lPO4g,4169
130
130
  schemathesis/specs/openapi/definitions.py,sha256=8htclglV3fW6JPBqs59lgM4LnA25Mm9IptXBPb_qUT0,93949
131
- schemathesis/specs/openapi/examples.py,sha256=V1fbsbMto_So7lTWnyGa7f3u9On2br8yZ-cPzcC2-Bw,21542
131
+ schemathesis/specs/openapi/examples.py,sha256=JsAy8Dexw36SUAO5MBB44ji3zEK9Y_JU5d2LRshjEI4,22023
132
132
  schemathesis/specs/openapi/formats.py,sha256=8AIS7Uey-Z1wm1WYRqnsVqHwG9d316PdqfKLqwUs7us,3516
133
133
  schemathesis/specs/openapi/media_types.py,sha256=F5M6TKl0s6Z5X8mZpPsWDEdPBvxclKRcUOc41eEwKbo,2472
134
134
  schemathesis/specs/openapi/parameters.py,sha256=ifu_QQCMUzsUHQAkvsOvLuokns6CzesssmQ3Nd3zxII,14594
@@ -157,8 +157,8 @@ schemathesis/transport/prepare.py,sha256=erYXRaxpQokIDzaIuvt_csHcw72iHfCyNq8VNEz
157
157
  schemathesis/transport/requests.py,sha256=46aplzhSmBupegPNMawma-iJWCegWkEd6mzdWLTpgM4,10742
158
158
  schemathesis/transport/serialization.py,sha256=igUXKZ_VJ9gV7P0TUc5PDQBJXl_s0kK9T3ljGWWvo6E,10339
159
159
  schemathesis/transport/wsgi.py,sha256=KoAfvu6RJtzyj24VGB8e-Iaa9smpgXJ3VsM8EgAz2tc,6152
160
- schemathesis-4.0.21.dist-info/METADATA,sha256=HP1W2NG4U59FCpvqyJKxlh5Gcl-vtEOKJvRYWGaCmuw,8472
161
- schemathesis-4.0.21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
- schemathesis-4.0.21.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
163
- schemathesis-4.0.21.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
164
- schemathesis-4.0.21.dist-info/RECORD,,
160
+ schemathesis-4.0.23.dist-info/METADATA,sha256=W_qDuAIsI2Y8uOArbMl7ZAbJ_5obdoItSLB16qauEPM,8472
161
+ schemathesis-4.0.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
+ schemathesis-4.0.23.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
163
+ schemathesis-4.0.23.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
164
+ schemathesis-4.0.23.dist-info/RECORD,,