Repository navigation
Share poll-delay logic between search and preview, and test it offline - #35
Merged
Merged
Conversation
Search and preview polling now read x-ms-delay through one private _poll_delay function. Entries are trimmed, and an empty entry or one that isn't a whole number counts as 1000 ms instead of raising ValueError. tests/polling_test.py covers both loops with a fake session and a fake clock, so it runs in milliseconds with no network or API key.
Treat a delay past a signed 64-bit integer as 1000 ms, and cap the fake session at 20 requests so a loop that never stops fails instead of hanging. Add tests for millisecond elapsed time and for reading the delay from the latest response, and cover signed values in the not-a-number test.
The search helper always passed error_on_timeout, so the timeout error test never ran with the client's own default. Pass it only when a test sets it.
Parsing is shared, so preview keeps only the tests of its own loop. The sub-second and over-one-second cases are covered by the latest-response tests, and the timeout tests now also check that elapsed time is measured in milliseconds.
ad-mailosaur
approved these changes
Dec 4, 2026
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.
Problem
messages.searchandfiles.get_previeweach parse thex-ms-delayheader themselves, and a value that isn't a whole number makesint()raiseValueError. Neither polling loop has tests that run without the live API.Changes
_poll_delay(header, poll_count)inmailosaur/operations/_polling.py, used by both loops: no header, an empty entry or anything but ASCII digits waits 1000 ms; pollnuses entryn, and the last entry repeats.tests/polling_test.pywith the 9 tests (5 search, 4 preview) of the shared poll-delay spec, using a fake session and a fake clock, so they run offline without secrets. CI'spytestpicks them up too.