Complete API test tasks: fix schema, build test infra, add coverage#209
Open
SinanIT wants to merge 1 commit intoautomationExamples:mainfrom
Open
Complete API test tasks: fix schema, build test infra, add coverage#209SinanIT wants to merge 1 commit intoautomationExamples:mainfrom
SinanIT wants to merge 1 commit intoautomationExamples:mainfrom
Conversation
- Fixed pet schema where 'name' was typed as integer instead of string, that was the root cause of test_pet_schema failing - Created test_data.py to centralize endpoints, test constants, and a PetFactory that generates unique pets with sequential IDs. Keeps all the magic strings out of test files - Added conftest.py with a shared create_pet fixture and logging so test runs are easy to trace. Also cleans up irrelevant metadata from the HTML report - Every test creates its own data now, nothing depends on seed data or other tests. Ran into an issue where test_find_by_status_200 was silently passing on empty results for 'sold' so I added a guard for that - Built the store PATCH test with a fixture that sets up a fresh pet and order each time. After patching I also GET the pet back to make sure the status actually changed, not just trusting the response - Added a few edge case tests: invalid status on findByStatus (400) and patching a non-existent order (404) - Configured pytest.ini for auto HTML reporting and filtered out the noisy deprecation warnings from pytest internals - Found a couple bugs in app.py, noted in PR description"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Went through all three tasks. Fixed the schema bug, filled in the pet
tests, wrote the store PATCH test, and added some edge cases along
the way.
Changes
Schema (schemas.py)
The name field was typed as integer, changed it to string. Added order
and order_update_response schemas for the store test.
Test helpers (test_data.py)
Pulled endpoints, statuses, and expected messages into one place.
PetFactory generates unique pets with sequential IDs based on a
time offset, so tests never collide with each other even across runs.
ID ranges are separated so "nonexistent" IDs for 404 tests can't
accidentally match a created pet.
Shared fixtures (conftest.py)
create_pet fixture is shared across test files. Autouse logging
fixture so you can see which test is running. Also strips JAVA_HOME
from the HTML report metadata since it's not relevant.
Pet tests (test_pet.py) - 4 tests, 10 cases
run creates a pet with that status first so we're not relying on
whatever happens to be in the server. Checks status field and
schema on every item
string, checks 400 + error message
Store tests (test_store.py) - 2 tests, 3 cases
run. Parameterized for sold/available transitions. Validates
response schema, message, and does a follow-up GET to confirm
the pet status actually updated
Config (pytest.ini)
Verbose output, auto HTML report, filtered pytest deprecation noise.
Bugs found
message, {status} prints literally instead of the actual value
int converter entirely, returns raw HTML 404 instead of JSON