v6.58-beta - #661
Merged
Merged
Conversation
Two features had little or no test coverage. Both are now exercised, using the style that fits each one. Regulation solicitation workflow (unit tests, 38 cases) The whole regulation domain was untested: reg_solicitation_service was at 18%, reg_solicitation_attribute_service at 33% and reg_prioritization_service at 42%. The regulation tables live in a separate DDL file that neither CI nor `make test-setup` loads, so these are unit tests with a mocked db session and patched repository calls. Real SQLAlchemy model instances are used as rows, so column mapping and the services' attribute writes are exercised for real. Covered: solicitation read with its movement history (including the synthetic initial event and null-safe joins), stage movements with every side effect (schedule/transport date parsing from the dd/mm/yyyy hh:mm mask, type and risk updates, both undo actions), batch moves, manual creation of a solicitation plus its admission record, the attribute soft delete, and the prioritization queue (window-function count, age derivation). Two tests pin the READ_REGULATION / WRITE_REGULATION gate. Names proxy (integration tests, 43 cases) routes/names.py was at 36% and name_service's public API was untested — only the strategy classes had unit tests. These are integration tests: they authenticate for real, go through the routes and read the real schema_config row, with only the outbound boundary (aws / requests) patched, so no test reaches DynamoDB or an external host. Covered: the route-level search-term allow-list (accepting accents, apostrophes and hyphens; rejecting the characters that would reach an upstream URL), the degradation behaviour every patient list depends on (an unresolvable lookup yields the "Paciente <id>" placeholder rather than an error page), auth-token signing and verification, strategy selection from the tenant configuration (DynamoDB, internal JWT, getname-proxy), HTML escaping of externally supplied names, and batch-lookup chunking and ordering. Resulting coverage: the three regulation services 100%, routes/names.py 100%, name_service 57% -> 74%. Suite goes from 1788 to 1869 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KYV594ibCoXhT1GQhjZwxs
test: cover the regulation solicitation workflow and the names proxy
This reverts commit e4c9819.
This reverts commit cb0a8b6.
Adds integration coverage for two features that had none. GET /reports/prescription/history: the service and both repository queries were untested. The new tests pin the three synthetic "custom" events (origin creation, arrival, processing), the fact that they are suppressed for aggregated prescriptions, that the arrival date ignores Materiais items, that prescricao_audit rows written by an unknown user still render, and the merged ordering by date. Service and repository go from 31%/33% to 100%. POST /drugs/unit-conversion/<drug> and POST /drugs/process-scores/<drug>: the write half of the unit-conversion feature. The new tests cover the save being applied to every segment, medatributos being created from the substance reference when missing, the default measure unit being created when the substance names one the schema does not have, the fallback to "un", the upsert on re-save, the rejected payloads (empty list, zero factor, non-numeric factor, unknown drug), the permission gate, and that the save never reaches Lambda while process-scores sends the expected payload. unit_conversion_service goes from 49% to 91%. Both modules clean up after themselves: ids use the reserved >= 90000 / >= 100000 ranges wiped by clean_test_artifacts, and the measure units the save creates are removed by the module fixture. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aounHgxMPaoZmScdtHU2z
The shared "Secret & sensitive data scan" check is red on develop: gitleaks matches generic-api-key against the invented HS256 keys added with the names proxy tests, blocking every PR that targets develop. They are literals invented for that file, never a credential, so the fix is the suppression the check asks for -- an inline gitleaks:allow on each, with a comment saying why. Verified with gitleaks 8.30.1 (the version CI pins): one finding on origin/develop before, none after. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aounHgxMPaoZmScdtHU2z
test: cover prescription history report and unit conversion save
Adds coverage for two features that had none. Tests only, no production code changes. 1. GET /reports/drug-attributes/history (and the legacy /reports/antimicrobial/history alias): the attribute allowlist that guards the interpolated column name, the mapping of each key to its column, the widening to the patient's previous admissions, and the 400/401 paths. 2. The support knowledge-base search: unit tests for services/vector_search_service.search with both AWS boundaries mocked, and integration tests for POST /support/related-articles covering the config it hands to the search and how vector hits fold into articles. Coverage: reports_drug_attributes_service 33% -> 100%, vector_search_service 58% -> 100%, support_service 64% -> 73%. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EJss7x7K8zLo826yX6T5BR
The custom report list already exposes inactive reports to anyone holding READ_CUSTOM_REPORTS (ADMIN and CURATOR), but _validate_report only let WRITE_CUSTOM_REPORTS — which only ADMIN holds — past the "report is not active" check. A curator therefore saw an inactive report listed and got a 400 when opening or processing it. Accept READ_CUSTOM_REPORTS for the active check as well, so listing and opening agree. The reports_config "ignore CUSTOM" check still applies. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SDgKP7zcPKfozqqW38Nhs8
READ_CUSTOM_REPORTS now also opens inactive custom reports, so assert that only ADMIN and CURATOR hold it and that the ordinary READ_REPORTS roles do not. A future role edit that grants the permission fails these tests instead of silently widening access. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SDgKP7zcPKfozqqW38Nhs8
…s-access-pduyxt
There was a problem hiding this comment.
The changes in this PR introduce a well-designed onlyLatestExpireDate feature for protocols and enhance the TRAINING role permissions. The implementation correctly restricts protocol alerts to drugs prescribed on the current prescription date when enabled, includes comprehensive test coverage, and maintains backward compatibility with existing configs. The code follows established patterns and includes clear documentation. No critical issues were found that would block merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
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.
No description provided.