Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience methods on ParameterSet #1789

Closed
Stranger6667 opened this issue Oct 5, 2023 · 1 comment · Fixed by #1832
Closed

Add convenience methods on ParameterSet #1789

Stranger6667 opened this issue Oct 5, 2023 · 1 comment · Fixed by #1832
Labels
Component: Hooks Extensibility and customization Difficulty: Beginner Ideal for newcomers Hacktoberfest Priority: Low Cosmetic or low-impact changes
Milestone

Comments

@Stranger6667
Copy link
Member

Stranger6667 commented Oct 5, 2023

It could be useful in hooks, e.g. to check whether APIOperation contains some header (we leave case-insensitive for a while).

  1. Add a new contains method to the ParameterSet class, the method should accept name of type str
  2. The implementation should reuse the get method and check whether its result is None
  3. Inside test/specs/openapi/parameters/test_simple_payloads.py add a new function test_parameter_set_get
  4. This test function could have a setup like this:
import schemathesis

# ... other tests omitted for brevity

def test_parameter_set_get(make_openapi_3_schema):
    header = {"in": "header", "name": "id", "required": True, "schema": {}}
    raw_schema = make_openapi_3_schema(parameters=[header])
    schema = schemathesis.from_dict(raw_schema)
  1. Use the new method from step 1 on schema["/users"]["POST"].headers inside this test and verify that it contains the header with the name id and does not contain the header with the name unknown
@EkaterinaZaritskaia
Copy link

Hi, I'll try to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Hooks Extensibility and customization Difficulty: Beginner Ideal for newcomers Hacktoberfest Priority: Low Cosmetic or low-impact changes
Projects
None yet
2 participants