Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
FHIR-2646
  • Loading branch information
Bloom committed Dec 18, 2024
1 parent 8f5a0fa commit 1188542
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
9 changes: 5 additions & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Markdown.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (venv4)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
3 changes: 1 addition & 2 deletions build_support/pants/flake8.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ max-complexity = 11
ignore = E203,W503
per_file_ignores =
; Make flake8 ignore late module imports just like Ruff
utils/tests/*.py: E402
analyze_har_files/tests/*.py: E402
; utils/tests/*.py: E402
6 changes: 6 additions & 0 deletions jupyter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ python_sources(
sources = ["dbgap_fhir.py"],
dependencies = [":dbgap_fhir_requirements"],
)

python_test(
name = "dbgap_fhir_test",
source = "dbgap_fhir_test.py",
dependencies = [":dbgap_fhir_src"],
)
18 changes: 18 additions & 0 deletions jupyter/test_dbgap_fhir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest.mock import patch, MagicMock
from jupyter.dbgap_fhir import DbGapFHIR, obs_to_df, prettyprint



@patch('requests.Session')
def test_run_query_with_limit(MockSession):
mock_session = MockSession.return_value
mock_response = MagicMock()
mock_response.json.return_value = {"entry": [{"resource": {"id": "1"}}]}
mock_response.content = b'{"entry": [{"resource": {"id": "1"}}]}'
mock_session.get.return_value = mock_response

client = DbGapFHIR(fhir_server="http://example.com")
result = client.run_query("Patient", limit=True)

assert len(result) == 1
assert result[0]["id"] == "1"

0 comments on commit 1188542

Please sign in to comment.