robotframework-openapitools 1.0.0b4__py3-none-any.whl → 1.0.0b5__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.
Files changed (30) hide show
  1. OpenApiDriver/openapi_executors.py +7 -3
  2. OpenApiDriver/openapidriver.libspec +3 -3
  3. OpenApiLibCore/__init__.py +0 -0
  4. OpenApiLibCore/data_generation/__init__.py +0 -0
  5. OpenApiLibCore/data_generation/body_data_generation.py +4 -4
  6. OpenApiLibCore/data_generation/data_generation_core.py +18 -45
  7. OpenApiLibCore/data_invalidation.py +1 -5
  8. OpenApiLibCore/dto_base.py +31 -22
  9. OpenApiLibCore/dto_utils.py +31 -3
  10. OpenApiLibCore/localized_faker.py +0 -0
  11. OpenApiLibCore/models.py +26 -18
  12. OpenApiLibCore/openapi_libcore.libspec +26 -26
  13. OpenApiLibCore/openapi_libcore.py +35 -26
  14. OpenApiLibCore/parameter_utils.py +3 -3
  15. OpenApiLibCore/path_functions.py +5 -6
  16. OpenApiLibCore/path_invalidation.py +5 -7
  17. OpenApiLibCore/protocols.py +6 -0
  18. OpenApiLibCore/request_data.py +0 -0
  19. OpenApiLibCore/resource_relations.py +4 -2
  20. OpenApiLibCore/validation.py +4 -9
  21. OpenApiLibCore/value_utils.py +1 -1
  22. openapi_libgen/generator.py +2 -2
  23. openapi_libgen/parsing_utils.py +9 -5
  24. openapi_libgen/spec_parser.py +4 -4
  25. {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.0b5.dist-info}/METADATA +1 -1
  26. robotframework_openapitools-1.0.0b5.dist-info/RECORD +40 -0
  27. robotframework_openapitools-1.0.0b4.dist-info/RECORD +0 -40
  28. {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.0b5.dist-info}/LICENSE +0 -0
  29. {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.0b5.dist-info}/WHEEL +0 -0
  30. {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.0b5.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <keywordspec name="OpenApiLibCore" type="LIBRARY" format="HTML" scope="SUITE" generated="2025-05-11T17:22:53+00:00" specversion="6" source="/workspaces/robotframework-openapitools/src/OpenApiLibCore/openapi_libcore.py" lineno="174">
3
- <version>1.0.0b3</version>
2
+ <keywordspec name="OpenApiLibCore" type="LIBRARY" format="HTML" scope="SUITE" generated="2025-06-09T18:38:28+00:00" specversion="6" source="/workspaces/robotframework-openapitools/src/OpenApiLibCore/openapi_libcore.py" lineno="175">
3
+ <version>1.0.0b5</version>
4
4
  <doc>&lt;p&gt;Main class providing the keywords and core logic to interact with an OpenAPI server.&lt;/p&gt;
5
5
  &lt;p&gt;Visit the &lt;a href="https://github.com/MarketSquare/robotframework-openapi-libcore"&gt;library page&lt;/a&gt; for an introduction.&lt;/p&gt;</doc>
6
6
  <tags>
7
7
  </tags>
8
8
  <inits>
9
- <init name="__init__" lineno="182">
9
+ <init name="__init__" lineno="183">
10
10
  <arguments repr="source: str, origin: str = , base_path: str = , response_validation: ValidationLevel = WARN, disable_server_validation: bool = True, mappings_path: str | Path = , invalid_property_default_response: int = 422, default_id_property_name: str = id, faker_locale: str | list[str] = , require_body_for_invalid_url: bool = False, recursion_limit: int = 1, recursion_default: JSON = {}, username: str = , password: str = , security_token: str = , auth: AuthBase | None = None, cert: str | tuple[str, str] = , verify_tls: bool | str = True, extra_headers: Mapping[str, str] = {}, cookies: MutableMapping[str, str] | RequestsCookieJar | None = None, proxies: MutableMapping[str, str] | None = None">
11
11
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="source: str">
12
12
  <name>source</name>
@@ -208,7 +208,7 @@
208
208
  </init>
209
209
  </inits>
210
210
  <keywords>
211
- <kw name="Assert Href To Resource Is Valid" lineno="722">
211
+ <kw name="Assert Href To Resource Is Valid" lineno="729">
212
212
  <arguments repr="href: str, referenced_resource: dict[str, JSON]">
213
213
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="href: str">
214
214
  <name>href</name>
@@ -225,7 +225,7 @@
225
225
  <doc>&lt;p&gt;Attempt to GET the resource referenced by the &lt;span class="name"&gt;href&lt;/span&gt; and validate it's equal to the provided &lt;span class="name"&gt;referenced_resource&lt;/span&gt; object / dictionary.&lt;/p&gt;</doc>
226
226
  <shortdoc>Attempt to GET the resource referenced by the `href` and validate it's equal to the provided `referenced_resource` object / dictionary.</shortdoc>
227
227
  </kw>
228
- <kw name="Authorized Request" lineno="642">
228
+ <kw name="Authorized Request" lineno="649">
229
229
  <arguments repr="url: str, method: str, params: dict[str, Any] | None = None, headers: dict[str, str] | None = None, json_data: JSON | None = None, data: Any | None = None, files: Any | None = None">
230
230
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
231
231
  <name>url</name>
@@ -288,7 +288,7 @@
288
288
  &lt;p&gt;&amp;gt; Note: provided username / password or auth objects take precedence over token based security&lt;/p&gt;</doc>
289
289
  <shortdoc>Perform a request using the security token or authentication set in the library.</shortdoc>
290
290
  </kw>
291
- <kw name="Ensure In Use" lineno="627">
291
+ <kw name="Ensure In Use" lineno="634">
292
292
  <arguments repr="url: str, resource_relation: IdReference">
293
293
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
294
294
  <name>url</name>
@@ -302,7 +302,7 @@
302
302
  <doc>&lt;p&gt;Ensure that the (right-most) &lt;span class="name"&gt;id&lt;/span&gt; of the resource referenced by the &lt;span class="name"&gt;url&lt;/span&gt; is used by the resource defined by the &lt;span class="name"&gt;resource_relation&lt;/span&gt;.&lt;/p&gt;</doc>
303
303
  <shortdoc>Ensure that the (right-most) `id` of the resource referenced by the `url` is used by the resource defined by the `resource_relation`.</shortdoc>
304
304
  </kw>
305
- <kw name="Get Ids From Url" lineno="592">
305
+ <kw name="Get Ids From Url" lineno="599">
306
306
  <arguments repr="url: str">
307
307
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
308
308
  <name>url</name>
@@ -315,7 +315,7 @@
315
315
  <doc>&lt;p&gt;Perform a GET request on the &lt;span class="name"&gt;url&lt;/span&gt; and return the list of resource &lt;span class="name"&gt;ids&lt;/span&gt; from the response.&lt;/p&gt;</doc>
316
316
  <shortdoc>Perform a GET request on the `url` and return the list of resource `ids` from the response.</shortdoc>
317
317
  </kw>
318
- <kw name="Get Invalid Body Data" lineno="489">
318
+ <kw name="Get Invalid Body Data" lineno="496">
319
319
  <arguments repr="url: str, method: str, status_code: int, request_data: RequestData">
320
320
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
321
321
  <name>url</name>
@@ -342,7 +342,7 @@
342
342
  &lt;p&gt;&amp;gt; Note: applicable UniquePropertyValueConstraint and IdReference Relations are considered before changes to &lt;span class="name"&gt;json_data&lt;/span&gt; are made.&lt;/p&gt;</doc>
343
343
  <shortdoc>Return `json_data` based on the `dto` on the `request_data` that will cause the provided `status_code` for the `method` operation on the `url`.</shortdoc>
344
344
  </kw>
345
- <kw name="Get Invalidated Parameters" lineno="512">
345
+ <kw name="Get Invalidated Parameters" lineno="519">
346
346
  <arguments repr="status_code: int, request_data: RequestData">
347
347
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="status_code: int">
348
348
  <name>status_code</name>
@@ -366,7 +366,7 @@
366
366
  <doc>&lt;p&gt;Returns a version of &lt;span class="name"&gt;params, headers&lt;/span&gt; as present on &lt;span class="name"&gt;request_data&lt;/span&gt; that has been modified to cause the provided &lt;span class="name"&gt;status_code&lt;/span&gt;.&lt;/p&gt;</doc>
367
367
  <shortdoc>Returns a version of `params, headers` as present on `request_data` that has been modified to cause the provided `status_code`.</shortdoc>
368
368
  </kw>
369
- <kw name="Get Invalidated Url" lineno="602">
369
+ <kw name="Get Invalidated Url" lineno="609">
370
370
  <arguments repr="valid_url: str, path: str = , expected_status_code: int = 404">
371
371
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="valid_url: str">
372
372
  <name>valid_url</name>
@@ -385,10 +385,10 @@
385
385
  </arguments>
386
386
  <returntype name="str" typedoc="string"/>
387
387
  <doc>&lt;p&gt;Return an url with all the path parameters in the &lt;span class="name"&gt;valid_url&lt;/span&gt; replaced by a random UUID if no PathPropertiesConstraint is mapped for the &lt;span class="name"&gt;"get"&lt;/span&gt; operation on the mapped &lt;a href="#type-Path" class="name"&gt;path&lt;/a&gt; and &lt;span class="name"&gt;expected_status_code&lt;/span&gt;. If a PathPropertiesConstraint is mapped, the &lt;span class="name"&gt;invalid_value&lt;/span&gt; is returned.&lt;/p&gt;
388
- &lt;p&gt;Raises ValueError if the valid_url cannot be invalidated.&lt;/p&gt;</doc>
388
+ &lt;p&gt;Raises: ValueError if the valid_url cannot be invalidated.&lt;/p&gt;</doc>
389
389
  <shortdoc>Return an url with all the path parameters in the `valid_url` replaced by a random UUID if no PathPropertiesConstraint is mapped for the `"get"` operation on the mapped `path` and `expected_status_code`. If a PathPropertiesConstraint is mapped, the `invalid_value` is returned.</shortdoc>
390
390
  </kw>
391
- <kw name="Get Json Data With Conflict" lineno="528">
391
+ <kw name="Get Json Data With Conflict" lineno="535">
392
392
  <arguments repr="url: str, method: str, dto: Dto, conflict_status_code: int">
393
393
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
394
394
  <name>url</name>
@@ -414,7 +414,7 @@
414
414
  <doc>&lt;p&gt;Return &lt;span class="name"&gt;json_data&lt;/span&gt; based on the &lt;span class="name"&gt;UniquePropertyValueConstraint&lt;/span&gt; that must be returned by the &lt;span class="name"&gt;get_relations&lt;/span&gt; implementation on the &lt;span class="name"&gt;dto&lt;/span&gt; for the given &lt;span class="name"&gt;conflict_status_code&lt;/span&gt;.&lt;/p&gt;</doc>
415
415
  <shortdoc>Return `json_data` based on the `UniquePropertyValueConstraint` that must be returned by the `get_relations` implementation on the `dto` for the given `conflict_status_code`.</shortdoc>
416
416
  </kw>
417
- <kw name="Get Parameterized Path From Url" lineno="578">
417
+ <kw name="Get Parameterized Path From Url" lineno="585">
418
418
  <arguments repr="url: str">
419
419
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="url: str">
420
420
  <name>url</name>
@@ -425,7 +425,7 @@
425
425
  <doc>&lt;p&gt;Return the path as found in the &lt;span class="name"&gt;paths&lt;/span&gt; section based on the given &lt;span class="name"&gt;url&lt;/span&gt;.&lt;/p&gt;</doc>
426
426
  <shortdoc>Return the path as found in the `paths` section based on the given `url`.</shortdoc>
427
427
  </kw>
428
- <kw name="Get Request Data" lineno="478">
428
+ <kw name="Get Request Data" lineno="485">
429
429
  <arguments repr="path: str, method: str">
430
430
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
431
431
  <name>path</name>
@@ -440,7 +440,7 @@
440
440
  <doc>&lt;p&gt;Return an object with valid request data for body, headers and query params.&lt;/p&gt;</doc>
441
441
  <shortdoc>Return an object with valid request data for body, headers and query params.</shortdoc>
442
442
  </kw>
443
- <kw name="Get Request Values" lineno="437">
443
+ <kw name="Get Request Values" lineno="444">
444
444
  <arguments repr="path: str, method: str, overrides: Mapping[str, JSON] = {}">
445
445
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
446
446
  <name>path</name>
@@ -463,7 +463,7 @@
463
463
  <doc>&lt;p&gt;Return an object with all (valid) request values needed to make a request.&lt;/p&gt;</doc>
464
464
  <shortdoc>Return an object with all (valid) request values needed to make a request.</shortdoc>
465
465
  </kw>
466
- <kw name="Get Valid Id For Path" lineno="566">
466
+ <kw name="Get Valid Id For Path" lineno="573">
467
467
  <arguments repr="path: str">
468
468
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
469
469
  <name>path</name>
@@ -479,7 +479,7 @@
479
479
  &lt;p&gt;To prevent resource conflicts with other test cases, a new resource is created (by a POST operation) if possible.&lt;/p&gt;</doc>
480
480
  <shortdoc>Support keyword that returns the `id` for an existing resource at `path`.</shortdoc>
481
481
  </kw>
482
- <kw name="Get Valid Url" lineno="547">
482
+ <kw name="Get Valid Url" lineno="554">
483
483
  <arguments repr="path: str">
484
484
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
485
485
  <name>path</name>
@@ -492,7 +492,7 @@
492
492
  &lt;p&gt;&amp;gt; Note: if valid ids cannot be retrieved within the scope of the API, the &lt;span class="name"&gt;PathPropertiesConstraint&lt;/span&gt; Relation can be used. More information can be found &lt;a href="https://marketsquare.github.io/robotframework-openapitools/advanced_use.html"&gt;here&lt;/a&gt;.&lt;/p&gt;</doc>
493
493
  <shortdoc>This keyword returns a valid url for the given `path`.</shortdoc>
494
494
  </kw>
495
- <kw name="Perform Validated Request" lineno="691">
495
+ <kw name="Perform Validated Request" lineno="698">
496
496
  <arguments repr="path: str, status_code: int, request_values: RequestValues, original_data: Mapping[str, JSON] = {}">
497
497
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
498
498
  <name>path</name>
@@ -518,7 +518,7 @@
518
518
  <doc>&lt;p&gt;This keyword first calls the Authorized Request keyword, then the Validate Response keyword and finally validates, for &lt;span class="name"&gt;DELETE&lt;/span&gt; operations, whether the target resource was indeed deleted (OK response) or not (error responses).&lt;/p&gt;</doc>
519
519
  <shortdoc>This keyword first calls the Authorized Request keyword, then the Validate Response keyword and finally validates, for `DELETE` operations, whether the target resource was indeed deleted (OK response) or not (error responses).</shortdoc>
520
520
  </kw>
521
- <kw name="Set Auth" lineno="415">
521
+ <kw name="Set Auth" lineno="422">
522
522
  <arguments repr="auth: AuthBase">
523
523
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="auth: AuthBase">
524
524
  <name>auth</name>
@@ -529,7 +529,7 @@
529
529
  &lt;p&gt;After calling this keyword, subsequent requests will use the provided &lt;span class="name"&gt;auth&lt;/span&gt; instance.&lt;/p&gt;</doc>
530
530
  <shortdoc>Set the `auth` used for authentication after the library is imported.</shortdoc>
531
531
  </kw>
532
- <kw name="Set Basic Auth" lineno="403">
532
+ <kw name="Set Basic Auth" lineno="410">
533
533
  <arguments repr="username: str, password: str">
534
534
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="username: str">
535
535
  <name>username</name>
@@ -544,7 +544,7 @@
544
544
  &lt;p&gt;After calling this keyword, subsequent requests will use the provided credentials.&lt;/p&gt;</doc>
545
545
  <shortdoc>Set the `username` and `password` used for basic authentication after the library is imported.</shortdoc>
546
546
  </kw>
547
- <kw name="Set Extra Headers" lineno="425">
547
+ <kw name="Set Extra Headers" lineno="432">
548
548
  <arguments repr="extra_headers: dict[str, str]">
549
549
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="extra_headers: dict[str, str]">
550
550
  <name>extra_headers</name>
@@ -558,7 +558,7 @@
558
558
  &lt;p&gt;After calling this keyword, subsequent requests will use the provided &lt;span class="name"&gt;extra_headers&lt;/span&gt;.&lt;/p&gt;</doc>
559
559
  <shortdoc>Set the `extra_headers` used in requests after the library is imported.</shortdoc>
560
560
  </kw>
561
- <kw name="Set Origin" lineno="380">
561
+ <kw name="Set Origin" lineno="387">
562
562
  <arguments repr="origin: str">
563
563
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="origin: str">
564
564
  <name>origin</name>
@@ -570,7 +570,7 @@
570
570
  &lt;p&gt;In combination with OpenApiLibCore, the &lt;span class="name"&gt;origin&lt;/span&gt; can be used at any point to target another server that hosts an API that complies to the same OAS.&lt;/p&gt;</doc>
571
571
  <shortdoc>Set the `origin` after the library is imported.</shortdoc>
572
572
  </kw>
573
- <kw name="Set Security Token" lineno="394">
573
+ <kw name="Set Security Token" lineno="401">
574
574
  <arguments repr="security_token: str">
575
575
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="security_token: str">
576
576
  <name>security_token</name>
@@ -581,7 +581,7 @@
581
581
  &lt;p&gt;After calling this keyword, subsequent requests will use the provided token.&lt;/p&gt;</doc>
582
582
  <shortdoc>Set the `security_token` after the library is imported.</shortdoc>
583
583
  </kw>
584
- <kw name="Validate Response" lineno="737">
584
+ <kw name="Validate Response" lineno="744">
585
585
  <arguments repr="path: str, response: Response, original_data: Mapping[str, JSON] = {}">
586
586
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
587
587
  <name>path</name>
@@ -611,7 +611,7 @@
611
611
  &lt;/ul&gt;</doc>
612
612
  <shortdoc>Validate the `response` by performing the following validations: - validate the `response` against the openapi schema for the `path` - validate that the response does not contain extra properties - validate that a href, if present, refers to the correct resource - validate that the value for a property that is in the response is equal to the property value that was send - validate that no `original_data` is preserved when performing a PUT operation - validate that a PATCH operation only updates the provided properties</shortdoc>
613
613
  </kw>
614
- <kw name="Validate Response Using Validator" lineno="711">
614
+ <kw name="Validate Response Using Validator" lineno="718">
615
615
  <arguments repr="response: Response">
616
616
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="response: Response">
617
617
  <name>response</name>
@@ -621,7 +621,7 @@
621
621
  <doc>&lt;p&gt;Validate the &lt;span class="name"&gt;response&lt;/span&gt; against the OpenAPI Spec that is loaded during library initialization.&lt;/p&gt;</doc>
622
622
  <shortdoc>Validate the `response` against the OpenAPI Spec that is loaded during library initialization.</shortdoc>
623
623
  </kw>
624
- <kw name="Validate Send Response" lineno="767">
624
+ <kw name="Validate Send Response" lineno="774">
625
625
  <arguments repr="response: Response, original_data: Mapping[str, JSON] = {}">
626
626
  <arg kind="POSITIONAL_OR_NAMED" required="true" repr="response: Response">
627
627
  <name>response</name>
@@ -140,17 +140,18 @@ from robot.api.exceptions import FatalError
140
140
  from robot.libraries.BuiltIn import BuiltIn
141
141
 
142
142
  import OpenApiLibCore.data_generation as _data_generation
143
- import OpenApiLibCore.data_invalidation as di
144
- import OpenApiLibCore.path_functions as pf
145
- import OpenApiLibCore.path_invalidation as pi
146
- import OpenApiLibCore.resource_relations as rr
147
- import OpenApiLibCore.validation as val
143
+ import OpenApiLibCore.data_invalidation as _data_invalidation
144
+ import OpenApiLibCore.path_functions as _path_functions
145
+ import OpenApiLibCore.path_invalidation as _path_invalidation
146
+ import OpenApiLibCore.resource_relations as _resource_relations
147
+ import OpenApiLibCore.validation as _validation
148
148
  from OpenApiLibCore.annotations import JSON
149
149
  from OpenApiLibCore.dto_base import Dto, IdReference
150
150
  from OpenApiLibCore.dto_utils import (
151
151
  DEFAULT_ID_PROPERTY_NAME,
152
152
  get_dto_class,
153
153
  get_id_property_name,
154
+ get_path_dto_class,
154
155
  )
155
156
  from OpenApiLibCore.localized_faker import FAKE
156
157
  from OpenApiLibCore.models import (
@@ -184,7 +185,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
184
185
  source: str,
185
186
  origin: str = "",
186
187
  base_path: str = "",
187
- response_validation: val.ValidationLevel = val.ValidationLevel.WARN,
188
+ response_validation: _validation.ValidationLevel = _validation.ValidationLevel.WARN,
188
189
  disable_server_validation: bool = True,
189
190
  mappings_path: str | Path = "",
190
191
  invalid_property_default_response: int = 422,
@@ -359,12 +360,18 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
359
360
  self.get_dto_class = get_dto_class(
360
361
  mappings_module_name=mappings_module_name
361
362
  )
363
+ self.get_path_dto_class = get_path_dto_class(
364
+ mappings_module_name=mappings_module_name
365
+ )
362
366
  self.get_id_property_name = get_id_property_name(
363
367
  mappings_module_name=mappings_module_name
364
368
  )
365
369
  sys.path.pop()
366
370
  else:
367
371
  self.get_dto_class = get_dto_class(mappings_module_name="no mapping")
372
+ self.get_path_dto_class = get_path_dto_class(
373
+ mappings_module_name="no mapping"
374
+ )
368
375
  self.get_id_property_name = get_id_property_name(
369
376
  mappings_module_name="no mapping"
370
377
  )
@@ -500,7 +507,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
500
507
  > Note: applicable UniquePropertyValueConstraint and IdReference Relations are
501
508
  considered before changes to `json_data` are made.
502
509
  """
503
- return di.get_invalid_body_data(
510
+ return _data_invalidation.get_invalid_body_data(
504
511
  url=url,
505
512
  method=method,
506
513
  status_code=status_code,
@@ -518,7 +525,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
518
525
  Returns a version of `params, headers` as present on `request_data` that has
519
526
  been modified to cause the provided `status_code`.
520
527
  """
521
- return di.get_invalidated_parameters(
528
+ return _data_invalidation.get_invalidated_parameters(
522
529
  status_code=status_code,
523
530
  request_data=request_data,
524
531
  invalid_property_default_response=self.invalid_property_default_response,
@@ -533,7 +540,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
533
540
  returned by the `get_relations` implementation on the `dto` for the given
534
541
  `conflict_status_code`.
535
542
  """
536
- return di.get_json_data_with_conflict(
543
+ return _data_invalidation.get_json_data_with_conflict(
537
544
  url=url,
538
545
  base_url=self.base_url,
539
546
  method=method,
@@ -555,10 +562,10 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
555
562
  `PathPropertiesConstraint` Relation can be used. More information can be found
556
563
  [https://marketsquare.github.io/robotframework-openapitools/advanced_use.html | here].
557
564
  """
558
- return pf.get_valid_url(
565
+ return _path_functions.get_valid_url(
559
566
  path=path,
560
567
  base_url=self.base_url,
561
- get_dto_class=self.get_dto_class,
568
+ get_path_dto_class=self.get_path_dto_class,
562
569
  openapi_spec=self.openapi_spec,
563
570
  )
564
571
 
@@ -570,7 +577,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
570
577
  To prevent resource conflicts with other test cases, a new resource is created
571
578
  (by a POST operation) if possible.
572
579
  """
573
- return pf.get_valid_id_for_path(
580
+ return _path_functions.get_valid_id_for_path(
574
581
  path=path, get_id_property_name=self.get_id_property_name
575
582
  )
576
583
 
@@ -583,7 +590,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
583
590
  path_parts = path.split("/")
584
591
  # first part will be '' since a path starts with /
585
592
  path_parts.pop(0)
586
- parameterized_path = pf.get_parametrized_path(
593
+ parameterized_path = _path_functions.get_parametrized_path(
587
594
  path=path, openapi_spec=self.openapi_spec
588
595
  )
589
596
  return parameterized_path
@@ -594,7 +601,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
594
601
  Perform a GET request on the `url` and return the list of resource
595
602
  `ids` from the response.
596
603
  """
597
- return pf.get_ids_from_url(
604
+ return _path_functions.get_ids_from_url(
598
605
  url=url, get_id_property_name=self.get_id_property_name
599
606
  )
600
607
 
@@ -611,13 +618,13 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
611
618
  on the mapped `path` and `expected_status_code`.
612
619
  If a PathPropertiesConstraint is mapped, the `invalid_value` is returned.
613
620
 
614
- Raises ValueError if the valid_url cannot be invalidated.
621
+ Raises: ValueError if the valid_url cannot be invalidated.
615
622
  """
616
- return pi.get_invalidated_url(
623
+ return _path_invalidation.get_invalidated_url(
617
624
  valid_url=valid_url,
618
625
  path=path,
619
626
  base_url=self.base_url,
620
- get_dto_class=self.get_dto_class,
627
+ get_path_dto_class=self.get_path_dto_class,
621
628
  expected_status_code=expected_status_code,
622
629
  )
623
630
 
@@ -629,7 +636,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
629
636
  Ensure that the (right-most) `id` of the resource referenced by the `url`
630
637
  is used by the resource defined by the `resource_relation`.
631
638
  """
632
- rr.ensure_in_use(
639
+ _resource_relations.ensure_in_use(
633
640
  url=url,
634
641
  base_url=self.base_url,
635
642
  openapi_spec=self.openapi_spec,
@@ -700,7 +707,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
700
707
  Response keyword and finally validates, for `DELETE` operations, whether
701
708
  the target resource was indeed deleted (OK response) or not (error responses).
702
709
  """
703
- val.perform_validated_request(
710
+ _validation.perform_validated_request(
704
711
  path=path,
705
712
  status_code=status_code,
706
713
  request_values=request_values,
@@ -713,7 +720,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
713
720
  Validate the `response` against the OpenAPI Spec that is
714
721
  loaded during library initialization.
715
722
  """
716
- val.validate_response_using_validator(
723
+ _validation.validate_response_using_validator(
717
724
  response=response,
718
725
  response_validator=self.response_validator,
719
726
  )
@@ -726,7 +733,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
726
733
  Attempt to GET the resource referenced by the `href` and validate it's equal
727
734
  to the provided `referenced_resource` object / dictionary.
728
735
  """
729
- val.assert_href_to_resource_is_valid(
736
+ _validation.assert_href_to_resource_is_valid(
730
737
  href=href,
731
738
  origin=self.origin,
732
739
  base_url=self.base_url,
@@ -750,7 +757,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
750
757
  - validate that no `original_data` is preserved when performing a PUT operation
751
758
  - validate that a PATCH operation only updates the provided properties
752
759
  """
753
- val.validate_response(
760
+ _validation.validate_response(
754
761
  path=path,
755
762
  response=response,
756
763
  response_validator=self.response_validator,
@@ -774,7 +781,9 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
774
781
  In case a PATCH request, validate that only the properties that were patched
775
782
  have changed and that other properties are still at their pre-patch values.
776
783
  """
777
- val.validate_send_response(response=response, original_data=original_data)
784
+ _validation.validate_send_response(
785
+ response=response, original_data=original_data
786
+ )
778
787
 
779
788
  # endregion
780
789
 
@@ -844,7 +853,7 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
844
853
  refstring: str, # pylint: disable=unused-argument
845
854
  recursions: JSON, # pylint: disable=unused-argument
846
855
  ) -> JSON:
847
- return self._recursion_default
856
+ return self._recursion_default # pragma: no cover
848
857
 
849
858
  try:
850
859
  # Since parsing of the OAS and creating the Spec can take a long time,
@@ -892,11 +901,11 @@ class OpenApiLibCore: # pylint: disable=too-many-public-methods
892
901
 
893
902
  return parser, validation_spec, response_validator
894
903
 
895
- except ResolutionError as exception:
904
+ except ResolutionError as exception: # pragma: no cover
896
905
  raise FatalError(
897
906
  f"ResolutionError while trying to load openapi spec: {exception}"
898
907
  ) from exception
899
- except ValidationError as exception:
908
+ except ValidationError as exception: # pragma: no cover
900
909
  raise FatalError(
901
910
  f"ValidationError while trying to load openapi spec: {exception}"
902
911
  ) from exception
@@ -24,7 +24,7 @@ def get_safe_name_for_oas_name(oas_name: str) -> str:
24
24
  PARAMETER_REGISTRY[oas_name] = oas_name
25
25
  return oas_name
26
26
 
27
- safe_name = _convert_string_to_python_identifier(oas_name)
27
+ safe_name = convert_string_to_python_identifier(oas_name)
28
28
 
29
29
  if safe_name not in PARAMETER_REGISTRY:
30
30
  PARAMETER_REGISTRY[safe_name] = oas_name
@@ -36,7 +36,7 @@ def get_safe_name_for_oas_name(oas_name: str) -> str:
36
36
  # We're dealing with multiple oas_names that convert to the same safe_name.
37
37
  # To resolve this, a more verbose safe_name is generated. This is less user-friendly
38
38
  # but necessary to ensure an one-to-one mapping.
39
- verbose_safe_name = _convert_string_to_python_identifier(oas_name, verbose=True)
39
+ verbose_safe_name = convert_string_to_python_identifier(oas_name, verbose=True)
40
40
  if verbose_safe_name not in PARAMETER_REGISTRY:
41
41
  PARAMETER_REGISTRY[verbose_safe_name] = oas_name
42
42
  return verbose_safe_name
@@ -46,7 +46,7 @@ def _is_python_safe(name: str) -> bool:
46
46
  return name.isidentifier()
47
47
 
48
48
 
49
- def _convert_string_to_python_identifier(string: str, verbose: bool = False) -> str:
49
+ def convert_string_to_python_identifier(string: str, verbose: bool = False) -> str:
50
50
  def _convert_string_to_python_identifier() -> Generator[str, None, None]:
51
51
  string_iterator = iter(string)
52
52
 
@@ -8,9 +8,8 @@ from typing import Any
8
8
  from requests import Response
9
9
  from robot.libraries.BuiltIn import BuiltIn
10
10
 
11
- from OpenApiLibCore.dto_base import PathPropertiesConstraint
12
11
  from OpenApiLibCore.models import OpenApiObject
13
- from OpenApiLibCore.protocols import GetDtoClassType, GetIdPropertyNameType
12
+ from OpenApiLibCore.protocols import GetIdPropertyNameType, GetPathDtoClassType
14
13
  from OpenApiLibCore.request_data import RequestData
15
14
 
16
15
  run_keyword = BuiltIn().run_keyword
@@ -64,7 +63,7 @@ def get_parametrized_path(path: str, openapi_spec: OpenApiObject) -> str:
64
63
  def get_valid_url(
65
64
  path: str,
66
65
  base_url: str,
67
- get_dto_class: GetDtoClassType,
66
+ get_path_dto_class: GetPathDtoClassType,
68
67
  openapi_spec: OpenApiObject,
69
68
  ) -> str:
70
69
  try:
@@ -75,9 +74,9 @@ def get_valid_url(
75
74
  raise ValueError(
76
75
  f"{path} not found in paths section of the OpenAPI document."
77
76
  ) from None
78
- dto_class = get_dto_class(path=path, method="get")
79
- relations = dto_class.get_relations()
80
- paths = [p.path for p in relations if isinstance(p, PathPropertiesConstraint)]
77
+ dto_class = get_path_dto_class(path=path)
78
+ relations = dto_class.get_path_relations()
79
+ paths = [p.path for p in relations]
81
80
  if paths:
82
81
  url = f"{base_url}{choice(paths)}"
83
82
  return url
@@ -5,8 +5,7 @@ from uuid import uuid4
5
5
 
6
6
  from robot.libraries.BuiltIn import BuiltIn
7
7
 
8
- from OpenApiLibCore.dto_base import PathPropertiesConstraint
9
- from OpenApiLibCore.protocols import GetDtoClassType
8
+ from OpenApiLibCore.protocols import GetPathDtoClassType
10
9
 
11
10
  run_keyword = BuiltIn().run_keyword
12
11
 
@@ -15,16 +14,15 @@ def get_invalidated_url(
15
14
  valid_url: str,
16
15
  path: str,
17
16
  base_url: str,
18
- get_dto_class: GetDtoClassType,
17
+ get_path_dto_class: GetPathDtoClassType,
19
18
  expected_status_code: int,
20
19
  ) -> str:
21
- dto_class = get_dto_class(path=path, method="get")
22
- relations = dto_class.get_relations()
20
+ dto_class = get_path_dto_class(path=path)
21
+ relations = dto_class.get_path_relations()
23
22
  paths = [
24
23
  p.invalid_value
25
24
  for p in relations
26
- if isinstance(p, PathPropertiesConstraint)
27
- and p.invalid_value_error_code == expected_status_code
25
+ if p.invalid_value_error_code == expected_status_code
28
26
  ]
29
27
  if paths:
30
28
  url = f"{base_url}{choice(paths)}"
@@ -30,3 +30,9 @@ class GetIdPropertyNameType(Protocol):
30
30
  ) -> tuple[
31
31
  str, Callable[[str], str] | Callable[[int], int]
32
32
  ]: ... # pragma: no cover
33
+
34
+
35
+ class GetPathDtoClassType(Protocol):
36
+ def __init__(self, mappings_module_name: str) -> None: ... # pragma: no cover
37
+
38
+ def __call__(self, path: str) -> Type[Dto]: ... # pragma: no cover
File without changes
@@ -4,7 +4,7 @@ from requests import Response
4
4
  from robot.api import logger
5
5
  from robot.libraries.BuiltIn import BuiltIn
6
6
 
7
- import OpenApiLibCore.path_functions as pf
7
+ import OpenApiLibCore.path_functions as _path_functions
8
8
  from OpenApiLibCore.dto_base import IdReference
9
9
  from OpenApiLibCore.models import OpenApiObject
10
10
  from OpenApiLibCore.request_data import RequestData
@@ -22,7 +22,9 @@ def ensure_in_use(
22
22
 
23
23
  path = url.replace(base_url, "")
24
24
  path_parts = path.split("/")
25
- parameterized_path = pf.get_parametrized_path(path=path, openapi_spec=openapi_spec)
25
+ parameterized_path = _path_functions.get_parametrized_path(
26
+ path=path, openapi_spec=openapi_spec
27
+ )
26
28
  parameterized_path_parts = parameterized_path.split("/")
27
29
  for part, param_part in zip(
28
30
  reversed(path_parts), reversed(parameterized_path_parts)
@@ -75,7 +75,7 @@ def perform_validated_request(
75
75
  f"\nGot: {_json.dumps(response_json, indent=4, sort_keys=True)}"
76
76
  )
77
77
  raise AssertionError(
78
- f"Response status_code {response.status_code} was not {status_code}"
78
+ f"Response status_code {response.status_code} was not {status_code}."
79
79
  )
80
80
 
81
81
  run_keyword("validate_response", path, response, original_data)
@@ -90,7 +90,7 @@ def perform_validated_request(
90
90
  if response.ok:
91
91
  if get_response.ok:
92
92
  raise AssertionError(
93
- f"Resource still exists after deletion. Url was {request_values.url}"
93
+ f"Resource still exists after deletion. Url was {request_values.url}."
94
94
  )
95
95
  # if the path supports GET, 404 is expected, if not 405 is expected
96
96
  if get_response.status_code not in [404, 405]:
@@ -102,7 +102,7 @@ def perform_validated_request(
102
102
  elif not get_response.ok:
103
103
  raise AssertionError(
104
104
  f"Resource could not be retrieved after failed deletion. "
105
- f"Url was {request_values.url}, status_code was {get_response.status_code}"
105
+ f"Url was {request_values.url}, status_code was {get_response.status_code}."
106
106
  )
107
107
 
108
108
 
@@ -279,11 +279,6 @@ def validate_send_response(
279
279
  )
280
280
  return None
281
281
 
282
- # FIXME: this applies to removed code
283
- # POST on /resource_type/{id}/array_item/ will return the updated {id} resource
284
- # instead of a newly created resource. In this case, the send_json must be
285
- # in the array of the 'array_item' property on {id}
286
-
287
282
  send_path: str = response.request.path_url
288
283
  response_path = response_data.get("href", None)
289
284
  if response_path and send_path not in response_path:
@@ -380,6 +375,6 @@ def _get_response_object(
380
375
  path_operations = path_item.get_operations()
381
376
  operation_data = path_operations.get(method)
382
377
  if operation_data is None:
383
- raise ValueError(f"method '{method}' not supported for {path}")
378
+ raise ValueError(f"method '{method}' not supported for {path}.")
384
379
 
385
380
  return operation_data.responses[status]
@@ -98,7 +98,7 @@ def get_invalid_value(
98
98
  # Violate min / max values or length if possible
99
99
  try:
100
100
  values_out_of_bounds = value_schema.get_values_out_of_bounds(
101
- current_value=current_value
101
+ current_value=current_value # type: ignore[arg-type]
102
102
  )
103
103
  invalid_values += values_out_of_bounds
104
104
  except ValueError:
@@ -18,7 +18,7 @@ def load_openapi_spec(
18
18
  def recursion_limit_handler(
19
19
  limit: int, refstring: str, recursions: object
20
20
  ) -> object: # pylint: disable=unused-argument
21
- return recursion_default
21
+ return recursion_default # pragma: no cover
22
22
 
23
23
  parser = ResolvingParser(
24
24
  source,
@@ -69,7 +69,7 @@ def generate(
69
69
  return f"Generated {library_name} at {output_folder.resolve().as_posix()}/{module_name}"
70
70
 
71
71
 
72
- if __name__ == "__main__":
72
+ if __name__ == "__main__": # pragma: no cover
73
73
  source = sys.argv[1]
74
74
  destination = Path(sys.argv[2])
75
75
  library_name = sys.argv[3]