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 json response to entity creation error message #1119

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

dosas
Copy link
Collaborator

@dosas dosas commented Apr 3, 2024

Description of changes

Add json response to entity creation error message

  • Makes the error message information more detailed and informative
  • Possibility to write more precise assertions

There are some robottelo tests that would greatly benefit from more precise assertions on error messages, i.e.
tests/foreman/api/test_repository.py::TestRepository::test_negative_update_checksum_with_on_demand_policy (or other tests in this module)
I doubt that the supposed error message should be:

RuntimeError: The repository's publication is missing. Please run a 'complete sync' on MPvytWJ.","errors":["Task c7fa616b-2f71-4476-b581-1cae65a9eafd: RuntimeError: The repository's publication is missing. Please run a 'complete sync' on MPvytWJ."]}
Upstream API documentation, plugin, or feature links

None

Functional demonstration

Example:

before:

requests.exceptions.HTTPError: ('422 Client Error: Unprocessable Content for url: https://robottelo...')

after

requests.exceptions.HTTPError: ('422 Client Error: Unprocessable Content for url: https://...', {'displayMessage': 'Validation failed: When "Upstream URL" is set, "Releases/Distributions" must also be set!', 'errors': {'base': ['When "Upstream URL" is set, "Releases/Distributions" must also be set!']}}
Additional Information

None

* Makes the error message information more detailed and informative
* Possibility to write more precise assertions

Signed-off-by: dosas <[email protected]>
@dosas dosas force-pushed the add-json-to-error-message branch from 0fc2659 to 43b50eb Compare April 3, 2024 13:19
@omkarkhatavkar
Copy link

trigger: test-robottelo
pytest: -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py

Copy link

@omkarkhatavkar omkarkhatavkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Addition @dosas

@Satellite-QE
Copy link
Contributor

PRT Result

Build Number: 25
Build Status: SUCCESS
PRT Comment: pytest -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py --external-logging
Test Result : ========== 2 passed, 163 deselected, 23 warnings in 715.00s (0:11:54) ==========

@dosas
Copy link
Collaborator Author

dosas commented Apr 15, 2024

@omkarkhatavkar I sadly cannot set the labels.

Do we need additional reviewers?

@omkarkhatavkar
Copy link

@JacobCallahan @jyejare @ogajduse Looks an interesting PR. We need more review to merge this.

@jyejare jyejare added CherryPick PR needs CherryPick to previous branches 6.12.z 6.13.z 6.14.z 6.15.z labels Apr 16, 2024
Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK on the changes. However, @dosas are there any existing tests (in robottelo) that this change would impact?

@dosas
Copy link
Collaborator Author

dosas commented Apr 17, 2024

ACK on the changes. However, @dosas are there any existing tests (in robottelo) that this change would impact?

This should not affect the robottelo tests. The tests I have seen so far only check for requests.exceptions.HTTPError and not the content of the error message .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants