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 step to assert a field is not present #1901

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .generator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ def expect_response_has_field(context, response_path, field):
"""Check that a response has field."""


@then(parsers.parse('the response "{response_path}" does not have field "{field}"'))
def expect_response_has_field(context, response_path, field):
"""Check that a response path does not have field."""


@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
def expect_array_contains_object(context, response_path, key_path, value):
"""Check that a response attribute contains an object with the specified key and value."""
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,13 @@ def expect_response_has_field(context, response_path, field):
assert field in response_value


@then(parsers.parse('the response "{response_path}" does not have "{field}"'))
def expect_response_has_field(context, response_path, field):
"""Check that a response path has field."""
response_value = glom(context["api_request"]["response"][0], response_path)
assert field not in response_value


@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
def expect_array_contains_object(context, response_path, key_path, value):
from glom.core import PathAccessError
Expand Down
Loading