Live API healthcheck and test updates#151
Live API healthcheck and test updates#151DoraFgr wants to merge 7 commits intolichess-org:masterfrom
Conversation
- Introduced GitHub Actions workflow for live API healthcheck to validate API changes. - Added `test_live_api` target in Makefile to run tests against the live API without cassettes. - Implemented `--live-api-throttle` option in pytest for throttling between live API tests.
berserk/types/opening_explorer.py
Outdated
| # The id of the OTB master game | ||
| id: str | ||
| # The winner of the game. Draw if None | ||
| winner: Literal["white"] | Literal["black"] | None |
There was a problem hiding this comment.
probably rather not required Color from common
| # The year of the game | ||
| year: int | ||
| # The month and year of the game. For example "2023-06" | ||
| month: NotRequired[str] |
There was a problem hiding this comment.
I don't think this would be not required
There was a problem hiding this comment.
I am using this schemas doc as a reference, is there another reference I should be looking at?
| game: GameWithoutUci | None | ||
| # The opening info for this move | ||
| opening: Opening | None |
There was a problem hiding this comment.
Looking at this schema doc have it has required.
| game: GameWithoutUci | None | ||
| # The opening info for this move | ||
| opening: Opening | None |
There was a problem hiding this comment.
Looking at this schema doc have it has required.
| game: MastersGameWithoutUci | None | ||
| # The opening info for this move | ||
| opening: Opening | None |
There was a problem hiding this comment.
Looking at this schema doc have it has required.
berserk/types/opening_explorer.py
Outdated
| class PlayerOpeningStatistic(TypedDict): | ||
| # Number of game won by white from this position | ||
| white: int | ||
| # Number of game won by black from this position | ||
| draws: int | ||
| # Number draws from this position | ||
| black: int | ||
| # Opening info of this position | ||
| opening: Opening | None | ||
| # The list of moves played by the player from this position | ||
| moves: List[PlayerMove] | ||
| # recent games with this opening | ||
| recentGames: List[Game] | ||
| # Queue position for indexing (present when wait_for_indexing parameter used) | ||
| queuePosition: NotRequired[int] | ||
|
|
||
|
|
||
| class MastersOpeningStatistic(TypedDict): | ||
| # Number of game won by white from this position |
There was a problem hiding this comment.
can be refactored with generic typeddict https://alexocallaghan.com/python-typeddict-with-generics
There was a problem hiding this comment.
This is a good idea! I did not knew about generic type. Thanks!
e3cdf92 to
4daf82a
Compare
…formation to match current Lichess API schema.
- Updated `TestMasterGames` and `TestPlayerGames` to validate responses against typed-dicts `MastersOpeningStatistic` and `PlayerOpeningStatistic`. - Removed hardcoded assertions for response values in favor of validation utility. - Simplified the `test_stream` method to ensure at least one result is yielded from the stream.
…treaming marker to player game tests
4daf82a to
c369abb
Compare
|
Hi @kraktus, just following up on this PR. Let me know if there's anything else you'd like me to adjust or clarify. Thanks! |
|
Hi @kraktus, just following up on this PR. As mentionned I try to schema doc from the API as reference when determining the type of object. Let me know if there's anything else you'd like me to adjust or clarify. Thanks! |
PR: Live API healthcheck & opening-explorer typing fixes
This PR implements issue #65.
Goal
What changed
Tests & marker
streamingto mark tests that rely on streaming endpoints.Workflow & tooling
live-api-healthcheckto run tests against the live API on a schedule and on-demand.test_live_no_streamingto run the live tests while skipping streaming-marked tests. The workflow uses this target so the scheduled run completes reliably.Types and client
PlayerOpeningStatisticandMastersOpeningStatistic(inberserk/types/opening_explorer.py).client.opening_explorermethod signatures and the tests to use the new types.Workflow test:
To validate the workflow behavior three scenarios were tested:
These validate that the healthcheck detects regressions, avoids duplicate issues, and stays actionable.
Note
How to run locally
Checklist when adding a new endpoint
README.mdclient.users.get_user(), Correct:client.users.get()berserk/types/, exampleCHANGELOG.mdin theTo be releasedsection (to be created if necessary)