robotframework-schemathesislibrary 0.8.0__tar.gz → 0.10.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.
Potentially problematic release.
This version of robotframework-schemathesislibrary might be problematic. Click here for more details.
- {robotframework_schemathesislibrary-0.8.0/src/robotframework_schemathesislibrary.egg-info → robotframework_schemathesislibrary-0.10.0}/PKG-INFO +1 -1
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/pyproject.toml +2 -1
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/src/SchemathesisLibrary/__init__.py +84 -3
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0/src/robotframework_schemathesislibrary.egg-info}/PKG-INFO +1 -1
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/LICENSE +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/README.md +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/setup.cfg +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/src/robotframework_schemathesislibrary.egg-info/SOURCES.txt +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/src/robotframework_schemathesislibrary.egg-info/dependency_links.txt +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/src/robotframework_schemathesislibrary.egg-info/requires.txt +0 -0
- {robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/src/robotframework_schemathesislibrary.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robotframework-schemathesislibrary
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: Robot Framework SchemathesisLibrary to automatically create test cases from API specifications.
|
|
5
5
|
Author-email: Tatu Aalto <aalto.tatu@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "robotframework-schemathesislibrary"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.10.0"
|
|
4
4
|
description = "Robot Framework SchemathesisLibrary to automatically create test cases from API specifications."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name="Tatu Aalto", email="aalto.tatu@gmail.com" },
|
|
@@ -96,6 +96,7 @@ select = [
|
|
|
96
96
|
|
|
97
97
|
ignore = [
|
|
98
98
|
"ANN401",
|
|
99
|
+
"E501",
|
|
99
100
|
"TRY003",
|
|
100
101
|
"N999"
|
|
101
102
|
]
|
|
@@ -31,7 +31,7 @@ from schemathesis.core import NotSet
|
|
|
31
31
|
from schemathesis.core.result import Ok
|
|
32
32
|
from schemathesis.core.transport import Response
|
|
33
33
|
|
|
34
|
-
__version__ = "0.
|
|
34
|
+
__version__ = "0.10.0"
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
@dataclass
|
|
@@ -77,10 +77,42 @@ def from_case(case: Case) -> TestCaseData:
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
class SchemathesisLibrary(DynamicCore):
|
|
80
|
+
"""SchemathesisLibrary is a library for validating API cases using Schemathesis.
|
|
81
|
+
|
|
82
|
+
%TOC%
|
|
83
|
+
|
|
84
|
+
Example usage of the library and the `Call And Validate` keyword
|
|
85
|
+
|
|
86
|
+
Library must be imported with the `url` or `path` argument to specify the
|
|
87
|
+
OpenAPI schema. The library uses
|
|
88
|
+
[DataDriver|https://github.com/Snooz82/robotframework-datadriver] to generate
|
|
89
|
+
test cases from the OpenAPI schema by using
|
|
90
|
+
[Schemathesis|https://github.com/schemathesis/schemathesis/]. The library
|
|
91
|
+
creates test cases that takes one argument, `${case}`, which is a
|
|
92
|
+
Schemathesis
|
|
93
|
+
[Case|https://schemathesis.readthedocs.io/en/stable/reference/python/#schemathesis.Case]
|
|
94
|
+
object. The `Call And Validate` keyword can be used to call and validate
|
|
95
|
+
the case. The keyword will log the request and response details.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
| *** Settings ***
|
|
99
|
+
| Library SchemathesisLibrary url=http://127.0.0.1/openapi.json
|
|
100
|
+
|
|
|
101
|
+
| Test Template Wrapper
|
|
102
|
+
|
|
|
103
|
+
| *** Test Cases ***
|
|
104
|
+
| All Tests # This test is deleted by DataDriver
|
|
105
|
+
| Wrapper test_case_1
|
|
106
|
+
|
|
|
107
|
+
| *** Keywords ***
|
|
108
|
+
| Wrapper
|
|
109
|
+
| [Arguments] ${case}
|
|
110
|
+
| Call And Validate ${case}
|
|
111
|
+
"""
|
|
112
|
+
|
|
80
113
|
ROBOT_LIBRARY_VERSION = __version__
|
|
81
114
|
ROBOT_LISTENER_API_VERSION = 3
|
|
82
115
|
ROBOT_LIBRARY_SCOPE = "TEST SUITE"
|
|
83
|
-
"""SchemathesisLibrary is a library for validating API cases using Schemathesis."""
|
|
84
116
|
|
|
85
117
|
def __init__(
|
|
86
118
|
self,
|
|
@@ -90,6 +122,14 @@ class SchemathesisLibrary(DynamicCore):
|
|
|
90
122
|
path: "Path|None" = None,
|
|
91
123
|
url: "str|None" = None,
|
|
92
124
|
) -> None:
|
|
125
|
+
"""The SchemathesisLibrary can be initialized with the following arguments:
|
|
126
|
+
|
|
127
|
+
| =Argument= | =Description= |
|
|
128
|
+
| `headers` | Optional HTTP headers to be used schema is downloaded from `url`. |
|
|
129
|
+
| `max_examples` | Maximum number of examples to generate for each operation. Default is 5. |
|
|
130
|
+
| `path` | Path to the OpenAPI schema file. Using either `path` or `url` is mandatory. |
|
|
131
|
+
| `url` | URL where the OpenAPI schema can be downloaded. |
|
|
132
|
+
"""
|
|
93
133
|
self.ROBOT_LIBRARY_LISTENER = self
|
|
94
134
|
SchemathesisReader.options = Options(headers=headers, max_examples=max_examples, path=path, url=url)
|
|
95
135
|
self.data_driver = DataDriver(reader_class=SchemathesisReader)
|
|
@@ -110,7 +150,11 @@ class SchemathesisLibrary(DynamicCore):
|
|
|
110
150
|
base_url: "str|None" = None,
|
|
111
151
|
headers: "dict[str, Any]|None" = None,
|
|
112
152
|
) -> Response:
|
|
113
|
-
"""
|
|
153
|
+
"""Call and validate a Schemathesis case.
|
|
154
|
+
|
|
155
|
+
Example:
|
|
156
|
+
| ${response} = Call And Validate Case ${case}
|
|
157
|
+
"""
|
|
114
158
|
self.info(f"Case: {case.path} | {case.method} | {case.path_parameters}")
|
|
115
159
|
self._log_case(case, headers)
|
|
116
160
|
response = case.call_and_validate(base_url=base_url, headers=headers, auth=auth)
|
|
@@ -118,6 +162,43 @@ class SchemathesisLibrary(DynamicCore):
|
|
|
118
162
|
self.debug(f"Response: {response.headers} | {response.status_code} | {response.text}")
|
|
119
163
|
return response
|
|
120
164
|
|
|
165
|
+
@keyword
|
|
166
|
+
def call(
|
|
167
|
+
self,
|
|
168
|
+
case: Case,
|
|
169
|
+
*,
|
|
170
|
+
auth: "Any|None" = None,
|
|
171
|
+
base_url: "str|None" = None,
|
|
172
|
+
headers: "dict[str, Any]|None" = None,
|
|
173
|
+
) -> Response:
|
|
174
|
+
"""Call a Schemathesis case without validation.
|
|
175
|
+
|
|
176
|
+
The `Call` and `Validate Response` keywords can be used together
|
|
177
|
+
to call a case and validate the response.
|
|
178
|
+
|
|
179
|
+
Example:
|
|
180
|
+
| ${response} = Call Case ${case}
|
|
181
|
+
| Validate Response ${case} ${response}
|
|
182
|
+
"""
|
|
183
|
+
self.info(f"Calling case: {case.path} | {case.method} | {case.path_parameters}")
|
|
184
|
+
self._log_case(case)
|
|
185
|
+
response = case.call(base_url=base_url, headers=headers, auth=auth)
|
|
186
|
+
self._log_request(response)
|
|
187
|
+
return response
|
|
188
|
+
|
|
189
|
+
@keyword
|
|
190
|
+
def validate_response(self, case: Case, response: Response) -> None:
|
|
191
|
+
"""Validate a Schemathesis response.
|
|
192
|
+
|
|
193
|
+
The response is validated against the case's expectations.
|
|
194
|
+
The `Call` and `Validate Response` keywords can be used together
|
|
195
|
+
to call a case and validate the response. See the example from
|
|
196
|
+
`Call` keyword documentation.
|
|
197
|
+
"""
|
|
198
|
+
self.info(f"Validating response: {response.status_code} | {response.headers}")
|
|
199
|
+
case.validate_response(response)
|
|
200
|
+
self.info("Response validation passed.")
|
|
201
|
+
|
|
121
202
|
def info(self, message: str) -> None:
|
|
122
203
|
logger.info(message)
|
|
123
204
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robotframework-schemathesislibrary
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: Robot Framework SchemathesisLibrary to automatically create test cases from API specifications.
|
|
5
5
|
Author-email: Tatu Aalto <aalto.tatu@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
{robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/LICENSE
RENAMED
|
File without changes
|
{robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/README.md
RENAMED
|
File without changes
|
{robotframework_schemathesislibrary-0.8.0 → robotframework_schemathesislibrary-0.10.0}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|