-
Notifications
You must be signed in to change notification settings - Fork 1
Arm enhancement #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Arm enhancement #25
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
459e78c
Updated docstrings for endpoints & included in documentation
pendingintent ca7e46d
Reordered object lists
pendingintent a17ef28
Merge branch 'ui-layout' into update-endpoints
pendingintent 672df4a
Added docs for 2 new endpoints for viewing categories
pendingintent 0318e3f
Added concept category cache and corresponding tests
pendingintent ab410d2
Arm type now chosen from dropdown from codelist C174222
pendingintent 7ecf23f
Commented out arm.type debug
pendingintent 9b5c8ec
Added arm type and dataTypeOrigin properties and auditing
pendingintent 6240e8e
Removed temp shared memory and write-ahead logging database files fro…
pendingintent b597523
Added temp shared memory and write-ahead logging to sqlite db
pendingintent 31582eb
Arm audit added to edit.html
pendingintent e66ad60
Arm create includes type & data_origin_type
pendingintent 211eaa7
Update src/soa_builder/web/initialize_database.py
pendingintent 65309ac
Update src/soa_builder/web/app.py
pendingintent 7f09a34
Update src/soa_builder/web/app.py
pendingintent 12dcc0e
Update src/soa_builder/web/app.py
pendingintent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
|
|
||
| from soa_builder.web.app import ( | ||
| fetch_biomedical_concept_categories, | ||
| _bc_categories_cache, | ||
| ) | ||
|
|
||
|
|
||
| class DummyResponse: | ||
| def __init__(self, payload, status_code=200): | ||
| self._payload = payload | ||
| self.status_code = status_code | ||
|
|
||
| def json(self): | ||
| return self._payload | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def clear_categories_cache(): | ||
| _bc_categories_cache.clear() | ||
|
|
||
|
|
||
| def test_categories_cache_hit(monkeypatch): | ||
| call_count = SimpleNamespace(n=0) | ||
|
|
||
| payload = { | ||
| "_links": { | ||
| "categories": [ | ||
| { | ||
| "name": "CategoryA", | ||
| "_links": { | ||
| "self": {"href": "/mdr/bc/categories/A", "title": "TitleA"} | ||
| }, | ||
| }, | ||
| { | ||
| "name": "CategoryB", | ||
| "_links": { | ||
| "self": {"href": "/mdr/bc/categories/B", "title": "TitleB"} | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| def fake_get(url, headers=None, timeout=None): | ||
| call_count.n += 1 | ||
| return DummyResponse(payload) | ||
|
|
||
| monkeypatch.setattr("requests.get", fake_get) | ||
|
|
||
| # First call populates cache | ||
| cats1 = fetch_biomedical_concept_categories(force=False) | ||
| assert call_count.n == 1 | ||
| assert len(cats1) == 2 | ||
|
|
||
| # Second call within TTL should hit cache, no new HTTP call | ||
| cats2 = fetch_biomedical_concept_categories(force=False) | ||
| assert call_count.n == 1 | ||
| assert cats2 == cats1 | ||
|
|
||
|
|
||
| def test_categories_cache_force_bypass(monkeypatch): | ||
| call_count = SimpleNamespace(n=0) | ||
|
|
||
| payload1 = { | ||
| "_links": { | ||
| "categories": [ | ||
| { | ||
| "name": "CategoryA", | ||
| "_links": { | ||
| "self": {"href": "/mdr/bc/categories/A", "title": "TitleA"} | ||
| }, | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| payload2 = { | ||
| "_links": { | ||
| "categories": [ | ||
| { | ||
| "name": "CategoryA", | ||
| "_links": { | ||
| "self": {"href": "/mdr/bc/categories/A2", "title": "TitleA2"} | ||
| }, | ||
| }, | ||
| { | ||
| "name": "CategoryC", | ||
| "_links": { | ||
| "self": {"href": "/mdr/bc/categories/C", "title": "TitleC"} | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| def fake_get(url, headers=None, timeout=None): | ||
| call_count.n += 1 | ||
| # Return payload1 first, payload2 thereafter | ||
| return DummyResponse(payload1 if call_count.n == 1 else payload2) | ||
|
|
||
| monkeypatch.setattr("requests.get", fake_get) | ||
|
|
||
| # Populate cache | ||
| cats1 = fetch_biomedical_concept_categories(force=False) | ||
| assert call_count.n == 1 | ||
| assert [c["name"] for c in cats1] == ["CategoryA"] | ||
|
|
||
| # Force bypass should trigger a new HTTP call and new content | ||
| cats2 = fetch_biomedical_concept_categories(force=True) | ||
| assert call_count.n == 2 | ||
| assert [c["name"] for c in cats2] == ["CategoryA", "CategoryC"] | ||
|
|
||
| # Regular call after force should use cached latest content (no extra HTTP) | ||
| cats3 = fetch_biomedical_concept_categories(force=False) | ||
| assert call_count.n == 2 | ||
| assert cats3 == cats2 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The first column header 'Concepts' is ambiguous. Since the column contains a 'View Concepts' link, consider renaming to 'Actions' or 'View' for clarity.