[14.0][FIX] currency_rate_update_xe: send User-Agent, raise on HTTP error, mock tests#220
Open
klodr wants to merge 1 commit into
Open
[14.0][FIX] currency_rate_update_xe: send User-Agent, raise on HTTP error, mock tests#220klodr wants to merge 1 commit into
klodr wants to merge 1 commit into
Conversation
…rror, mock tests xe.com now returns HTTP 403 for requests without a User-Agent, and HTTP 404 for the dated endpoint (?date=YYYY-MM-DD) when the date is today or in the future. The scheduled run always ends on today, so test_cron / test_wizard failed with "0 != 1" (no rate produced). Backport to 14.0 of the fix from OCA#216 (16.0) and OCA#218 (17.0): - _request_data: send a User-Agent header, add a request timeout and raise_for_status(), so an HTTP error surfaces as a clean UserError instead of being silently parsed as empty HTML; - _get_historical_rate: fall back to the latest endpoint (no ?date=) for today and future days, as _get_latest_rate already does. The tests are also made hermetic: the HTTP layer is mocked (no real call to xe.com), covering the latest/historical fallback, the HTML parsing and the HTTP-error path. The test no longer depends on the live website, which is the root cause of the recurring CI failures raised in the comments of OCA#216 and OCA#218. Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
Author
|
@OCA/currency-maintainers @DarioLodeiros could you please review? This backports to 14.0 the xe.com fix from #216/#218 (User-Agent + latest-endpoint fallback) and additionally makes the tests hermetic (HTTP mocked), so they no longer depend on the live website. |
This was referenced Jun 20, 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.
Backport to 14.0 of the xe.com fix from #216 (16.0) and #218 (17.0), made hermetic.
Problem
test_cron/test_wizardfail withAssertionError: 0 != 1: xe.com now returns 403 for requests without aUser-Agent, and 404 on the dated endpoint (?date=<today>). The scheduled run always ends on today, so no rate is produced.Fix (as discussed in #216 / #218)
_request_data: send aUser-Agent, add a request timeout andraise_for_status()→ an HTTP error surfaces as a cleanUserErrorinstead of being parsed as empty HTML._get_historical_rate: fall back to the latest endpoint (no?date=) for today/future days, as_get_latest_ratealready does.Tests made hermetic
The tests no longer hit xe.com:
_request_datais mocked, and the latest/historical fallback, the HTML parsing and the HTTP-error path are all covered. This removes the dependency on the live website — the actual cause of the recurring red CI raised in the comments of #216 / #218.Context
This also unblocks the CI of #219 (
currency_rate_update_wise), currently held red only by these unrelatedxefailures.wiserelies on a stable authenticated JSON API rather than HTML scraping, so its own tests are already deterministic.Refs #216, #218.