test(spp_dci_client): assert outgoing-log integration at the log-service seam (#443) - #546
Open
gonzalesedwin1123 wants to merge 3 commits into
Open
gonzalesedwin1123 wants to merge 3 commits into
gonzalesedwin1123 wants to merge 3 commits into
Conversation
…ice seam TestOutgoingLogIntegration skips without spp_api_v2, so it had never run before the full-stack CI. The client writes the audit row through a separate, committed cursor on purpose (the row must survive the request's rollback); a TransactionCase at REPEATABLE READ cannot see that row and its latest-row query found an earlier class's committed success entry instead, so every status assertion failed against a stale row. test_401_retry also built an OAuth2 source without the fields its own constraint requires. The tests now patch OutgoingApiLogService.log_call and assert the kwargs of each call; one test lets the real write happen and reads the row back through a fresh cursor, scoped by a per-test service code, and removes it; the 401 test builds a valid OAuth2 source, keeps the token flow out of the patched HTTP client, and asserts the two calls in the order the code guarantees. Refs #443
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #546 +/- ##
==========================================
+ Coverage 76.91% 77.49% +0.58%
==========================================
Files 704 740 +36
Lines 45774 47416 +1642
==========================================
+ Hits 35205 36745 +1540
- Misses 10569 10671 +102
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Member
Author
|
Full-stack evidence: SP-MIS
|
gonzalesedwin1123
marked this pull request as ready for review
September 21, 2026 06:51
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.
Part of #443 (weekly ci-full red). Test-only; 8 tests in the SP-MIS stack, the largest single cluster.
Causes
The class had never run.
TestOutgoingLogIntegration.setUpClassskips withoutspp.api.outgoing.log, andspp_dci_client's dependency closure (base,spp_dci) does not reachspp_api_v2, so per-module CI always skipped it. The SP-MIS stack is the first database with both installed.Seven
test_make_request_logs_*tests —'success' != 'connection_error'etc., andduration_ms 0 not greater than 0._log_outgoing_callwrites the audit row throughregistry.cursor(), a separate connection that really commits (by design: the row must survive the request'sUserErrorrollback). In Odoo 19 a plainTransactionCaseis not in registry test mode (onlyHttpCaseis), and the test transaction runs at REPEATABLE READ, so rows committed after its snapshot are invisible while rows committed by earlier classes are visible._find_latest_logfiltered only onurl like "crvs.example.org", so every test foundTestClientService.test_make_request_with_oauth2's committed success row from a sub-millisecond mocked call, which explains every asserted value.test_401_retry_creates_two_log_entries— never satisfiable: it built an OAuth2 data source without token URL / client id / secret, so_check_oauth2_fieldsrefused the create (the constraint predates the test). Once fixed,get_headers()would have fetched the OAuth2 token through the same patchedhttpx.Clientand consumed the canned 401.Fix (test-only)
setUppatchesOutgoingApiLogService.log_call(autospec) and each test asserts the kwargs of the call(s) made — status, response code, endpoint, url, origin, error detail. The soft-dependency check, cursor open and service construction still run for real.duration_msis asserted>= 0(a mocked round trip is sub-millisecond).registry.cursor()(a new snapshot), scoped by a per-test uniqueservice_code, and removes it the same way.service_name,service_code,user_id).get_headers(the token flow is not under test) andclear_oauth2_token_cache, and asserts the two log calls in call order (inner retried success first, outer 401 second) rather than by row id.@unittest.skipUnless(True, ...)decorator is removed; the real guard is insetUpClass.Evidence
-i spp_dci_client,spp_api_v2 --test-tags /spp_dci_client:TestOutgoingLogIntegration: before7 failed, 1 error(s) of 9; after0 failed, 0 error(s) of 11.spp_dci_client19.0.2.0.1 → 19.0.2.0.2 + HISTORY (note: the module has no HISTORY entry for 2.0.1; pre-existing). README/index.html left for CI's generator.Noted, not changed
Every mocked
_make_requestin anyTransactionCaseon a database withspp_api_v2leaves a committedspp.api.outgoing.logrow behind (harmless in a throwaway CI database; makes "latest row" assertions order-dependent anywhere). Production behaviour is correct and intended.