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>
|
@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. |
… ImportError setuptools-odoo 3.1.8 imports the removed `pkg_resources` module, so the `setuptools-odoo-make-default` and `setuptools-odoo-get-requirements` hooks fail with `ModuleNotFoundError: No module named 'pkg_resources'` on recent setuptools (>= 81). This makes the pre-commit check red on every PR currently opened against this branch. Bump the hook to 3.3.2, same as OCA#217 for 16.0. Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
|
Folded #221 into this PR, because the two were deadlocking each other:
Each one fixed the check the other was failing, so neither could ever go green on its own — and since the CI runs the whole repo's test suite, the two failing The one-line @OCA/currency-maintainers — this is the unblocking change for the 14.0 branch; once it lands, the other pending 14.0 PRs should go green on rebase. |
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.