helix.fhir.client.sdk 4.2.14__py3-none-any.whl → 4.2.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  helix_fhir_client_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  helix_fhir_client_sdk/dictionary_parser.py,sha256=WrGkVAxMlUvVycRVrX7UZt2oP2e_Vk4-E8QibwTpHLM,3401
3
3
  helix_fhir_client_sdk/dictionary_writer.py,sha256=V7Bx9Z69s0LRYF6Lc6Xp0d-Gj0BnAVKA1vBuwf3JORE,1486
4
- helix_fhir_client_sdk/fhir_auth_mixin.py,sha256=p2QIYrCv7ZktutY7SzYizmHADahxBddRTSCqX1EKyHc,14465
4
+ helix_fhir_client_sdk/fhir_auth_mixin.py,sha256=L-_fwQbyojv6AoRUYkPSXWEsW7NRInvJ3wwYgINEtJs,14351
5
5
  helix_fhir_client_sdk/fhir_bundle_appender.py,sha256=t1hs7p_vXKC9MUFyUnN9dTuDhRF-kw-kkgVFtGHv9QQ,11749
6
- helix_fhir_client_sdk/fhir_client.py,sha256=P8xhTVNnJuo5UGbg5nrFOlAR4DAOlEstH27YtFHub00,35201
7
- helix_fhir_client_sdk/fhir_delete_mixin.py,sha256=1YiKddTJTUzzrRvG7WgSisXY8rfJAHPAEXTsOevrom8,6521
8
- helix_fhir_client_sdk/fhir_merge_mixin.py,sha256=YTUODvc2rqXhk5_kwNMFPykm1I9_omww2WUcDExMESg,15264
9
- helix_fhir_client_sdk/fhir_merge_resources_mixin.py,sha256=d5x41uL__yxMcaAnYDdmbpt529ZsOZcO0EBvnV1HSGI,36002
10
- helix_fhir_client_sdk/fhir_patch_mixin.py,sha256=YGcCPStoqVxWCYOaNI8vCKSFkAyRzP0YM_UWp4UKYro,5858
11
- helix_fhir_client_sdk/fhir_update_mixin.py,sha256=7psQTBsGPY1izuwn3yD4MGLjLVWQjqA_15_IeaUspew,6230
6
+ helix_fhir_client_sdk/fhir_client.py,sha256=dHfkruJZ1uPM4cmKcnn4HqI0BCDP3IwIqXSLvCu4IsY,37346
7
+ helix_fhir_client_sdk/fhir_delete_mixin.py,sha256=IRcJ5AJ7yrsc1HbjqYW5-jAcIEwG__9nEqwbvvC8qJ0,7532
8
+ helix_fhir_client_sdk/fhir_merge_mixin.py,sha256=h2lvpLDs5nvt9F1bcpd110LFuFXI2HW-uKrUs5TbW7I,17783
9
+ helix_fhir_client_sdk/fhir_merge_resources_mixin.py,sha256=QO2SeZa4Co69f_2YCz0_ss2dJb4xhVMkRdzbjLIJ-iI,35799
10
+ helix_fhir_client_sdk/fhir_patch_mixin.py,sha256=QLTsqhFLGi4gC_qQblnCA4skdiLw8h4QRlzvaeyFkl4,7249
11
+ helix_fhir_client_sdk/fhir_update_mixin.py,sha256=_Yx9yg809N8EXY07XlwHxSJLp-xIzpNg5erL92LOeww,7370
12
12
  helix_fhir_client_sdk/function_types.py,sha256=x95j6ix3Xa9b276Q741xX1jguqBuFT6EBLDw35_EoVM,3916
13
13
  helix_fhir_client_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  helix_fhir_client_sdk/well_known_configuration.py,sha256=hwKpqZoJHkHuCEOowoXk07ywEMMhr_rcmQHNKCUEgVk,221
@@ -38,13 +38,13 @@ helix_fhir_client_sdk/graph/test/test_graph_mixin.py,sha256=LNd4LVjryVLgzWeTXMDp
38
38
  helix_fhir_client_sdk/graph/test/test_simulate_graph_processor_mixin.py,sha256=EQDfhqJfUrP6SptXRP7ayEN7g5cZQMA00ccXzeXiSXM,46312
39
39
  helix_fhir_client_sdk/graph/test/test_simulate_graph_processor_mixin_caching.py,sha256=WFzKKHtKDcOOXjXRMKkRyJ64whoJoo9M9ST88ayvEbY,16176
40
40
  helix_fhir_client_sdk/open_telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- helix_fhir_client_sdk/open_telemetry/attribute_names.py,sha256=iUxm82t5-_qONL3Ld6LkzOwjuuCwcOptaJVBgCE4tps,169
42
- helix_fhir_client_sdk/open_telemetry/span_names.py,sha256=Y-k29sniK5beSgkEz335eYFpybaw3K_3VU-ayxLdrW0,380
41
+ helix_fhir_client_sdk/open_telemetry/attribute_names.py,sha256=mcPcgpaRe-hZDmPu8gLQo51E_-rllAk2OXMC9uK6EmM,328
42
+ helix_fhir_client_sdk/open_telemetry/span_names.py,sha256=sEuzUXxE9pSoAZti2YVifBqbo3r4SLTPlIUW4F2EuP0,548
43
43
  helix_fhir_client_sdk/queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- helix_fhir_client_sdk/queue/request_queue_mixin.py,sha256=L5HgWWARj-JoM7v4cradNonDK1aO1BQyl2MWZknP_PY,21806
44
+ helix_fhir_client_sdk/queue/request_queue_mixin.py,sha256=Q5ZyadT2nMX6TATsiy0FLXzzCpTbVjN0Gh-B_F0RGCk,21684
45
45
  helix_fhir_client_sdk/responses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  helix_fhir_client_sdk/responses/bundle_expander.py,sha256=ilR5eMgciSgzsdQvKB6bHtn9jtpvn3uS-EBz-hrahzo,1065
47
- helix_fhir_client_sdk/responses/fhir_client_protocol.py,sha256=QbkKa3x6czhy-QCLN1icctBSXBlLnll1Lj9kMdFm914,7002
47
+ helix_fhir_client_sdk/responses/fhir_client_protocol.py,sha256=IWM7LNQ1ZbgaySLGqpCwWAKyArT5HgBdNhkmSEivNMo,7100
48
48
  helix_fhir_client_sdk/responses/fhir_delete_response.py,sha256=0K11vyfZ0LtL-G61NHzDqHrZgEHjMVZr00VWpWcktZA,2941
49
49
  helix_fhir_client_sdk/responses/fhir_get_response.py,sha256=3PXvFoMZ7ix2ZzucIjY-49RL3foLR07dD57BdulyMGI,17657
50
50
  helix_fhir_client_sdk/responses/fhir_merge_response.py,sha256=uvUjEGJgMDlAkcc5_LjgAsTFZqREQMlV79sbxUZwtwE,2862
@@ -104,7 +104,7 @@ helix_fhir_client_sdk/utilities/hash_util.py,sha256=YNUy7-IC_OtC0l-T45UO9UkA-_ps
104
104
  helix_fhir_client_sdk/utilities/list_chunker.py,sha256=2h2k5CCFmOhICaugOx6UI-9dh4q5w1lVdF7WQLX0LCM,1456
105
105
  helix_fhir_client_sdk/utilities/ndjson_chunk_streaming_parser.py,sha256=3TCYfWVCEpJbqRxqlSDsGnFnraO4T9bxzYdShvu6Pos,1954
106
106
  helix_fhir_client_sdk/utilities/practitioner_generator.py,sha256=gneCAXNDNEphBY-Nc2nMQBbEWJgHcjvv3S8JQ75yiJI,3778
107
- helix_fhir_client_sdk/utilities/retryable_aiohttp_client.py,sha256=yjZ0hUWNG4JD8sWgPGXYmYsY_wzaJM0cWD_Vo2LG8Sg,21095
107
+ helix_fhir_client_sdk/utilities/retryable_aiohttp_client.py,sha256=8DdzqTmIY1hWlxmEXOxycBpa72wTo-vsAtcLO4hpnmQ,22605
108
108
  helix_fhir_client_sdk/utilities/retryable_aiohttp_response.py,sha256=DvNX6WO1m2Hz6LoI5CwSPDECPd8oDsqRCVsyq_Oxf-0,3542
109
109
  helix_fhir_client_sdk/utilities/retryable_aiohttp_url_result.py,sha256=Gdmvn6qIM2JF0YOhobQUHY41fCxvYyaths_CZs0iJfo,616
110
110
  helix_fhir_client_sdk/utilities/url_checker.py,sha256=_JRSIvu7WNXh2OA79HJbEEiomGT-quGhAUGh44-9824,3580
@@ -130,10 +130,10 @@ helix_fhir_client_sdk/validators/async_fhir_validator.py,sha256=Bgiw5atbc5YzBYpk
130
130
  helix_fhir_client_sdk/validators/fhir_validator.py,sha256=HWBldSEB9yeKIcnLcV8R-LoTzwT_OMu8SchtUUBKzys,2331
131
131
  helix_fhir_client_sdk/validators/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
132
132
  helix_fhir_client_sdk/validators/test/test_async_fhir_validator.py,sha256=RmSowjPUdZee5nYuYujghxWyqJ20cu7U0lJFtFT-ZBs,3285
133
- helix_fhir_client_sdk-4.2.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
133
+ helix_fhir_client_sdk-4.2.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
134
134
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
135
135
  tests/logger_for_test.py,sha256=UC-7F6w6fDsUIYf37aRnvUdiUUVk8qkJEUSuO17NQnI,1525
136
- tests/test_fhir_client_clone.py,sha256=tKL-Kz9sUc1mTkaGO0QQtgO5_8ZuBdDICm_oNTV12sY,4030
136
+ tests/test_fhir_client_clone.py,sha256=c5y1rWJ32nBSUnK1FfyymY005dNowd4Nf1xrbuQolNk,5368
137
137
  tests/test_get_nested_property.py,sha256=dA7eNmPJuwzQTViORRmJkcn9RAZzxeajSxUghobHpAo,2381
138
138
  tests/async/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
139
  tests/async/test_async_fhir_client_fetch_response_in_chunks.py,sha256=Ql95DuOqaidFL6u553f-Bkp4Rsd662C__NA-5sw0KL0,3993
@@ -153,6 +153,7 @@ tests/async/test_async_real_fhir_server_get_patients.py,sha256=0oMnUJg1KEspJ5_4e
153
153
  tests/async/test_async_real_fhir_server_get_patients_error.py,sha256=_s7chLogAg0yKgGpsq1o9_dDHBrzGaRWBAo8agFTN6U,1914
154
154
  tests/async/test_benchmark_compress.py,sha256=q1gDG7qXvof-3uVAqJlZAW7uO8cR0vEeDfzl-iwIEtY,16470
155
155
  tests/async/test_benchmark_merge.py,sha256=ME0Pow_IXpIaVGWvq3ii7dGltXcz-3DGxz2gGF4LmYQ,19830
156
+ tests/async/test_retryable_client_session_management.py,sha256=cOAE0wGkh3cv0AS187nujeial3gGEu1VlOJ5b9-LaCI,5360
156
157
  tests/async/fhir_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
157
158
  tests/async/fhir_server/test_async_real_fhir_server_get_graph_large.py,sha256=fM2MPF47nDF2Qwj2AkdTZ2CfvgUYGN4AVIS253KC9MQ,9430
158
159
  tests/async/fhir_server/test_async_real_fhir_server_get_patients_large.py,sha256=rXRF8E8Al7XANCmef1d_WqxSA9TVQjVC7B41OZaEQlY,5583
@@ -212,7 +213,7 @@ tests_integration/test_emr_server_auth.py,sha256=2I4QUAspQN89uGf6JB2aVuYaBeDnRJz
212
213
  tests_integration/test_firely_fhir.py,sha256=ll6-plwQrKfdrEyfbw0wLTC1jB-Qei1Mj-81tYTl5eQ,697
213
214
  tests_integration/test_merge_vs_smart_merge_behavior.py,sha256=LrIuyxzw0YLaTjcRtG0jzy0M6xSv9qebmdBtMPDcacQ,3733
214
215
  tests_integration/test_staging_server_graph.py,sha256=5RfMxjhdX9o4-n_ZRvze4Sm8u8NjRijRLDpqiz8qD_0,7132
215
- helix_fhir_client_sdk-4.2.14.dist-info/METADATA,sha256=k5OlcbCO8MQ7ButJErmJBVXEV7nOSZ9oDHlXxomX_a4,5845
216
- helix_fhir_client_sdk-4.2.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
217
- helix_fhir_client_sdk-4.2.14.dist-info/top_level.txt,sha256=BRnDS6ceQxs-4u2jXznATObgP8G2cGAerlH0ZS4sJ6M,46
218
- helix_fhir_client_sdk-4.2.14.dist-info/RECORD,,
216
+ helix_fhir_client_sdk-4.2.16.dist-info/METADATA,sha256=AHcaKMqC3ICIbjD_Fr8CXs8MxOXLzdyh3A76J-SVYMk,7210
217
+ helix_fhir_client_sdk-4.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
218
+ helix_fhir_client_sdk-4.2.16.dist-info/top_level.txt,sha256=BRnDS6ceQxs-4u2jXznATObgP8G2cGAerlH0ZS4sJ6M,46
219
+ helix_fhir_client_sdk-4.2.16.dist-info/RECORD,,
@@ -0,0 +1,155 @@
1
+ """
2
+ Tests for RetryableAioHttpClient session lifecycle management.
3
+
4
+ This module tests that sessions are properly closed or kept open depending on
5
+ whether they were created internally or provided by the user.
6
+ """
7
+
8
+ import aiohttp
9
+ import pytest
10
+
11
+ from helix_fhir_client_sdk.utilities.retryable_aiohttp_client import RetryableAioHttpClient
12
+
13
+
14
+ @pytest.mark.asyncio
15
+ async def test_internal_session_is_closed_after_exit() -> None:
16
+ """Test that internally created sessions are closed when context exits"""
17
+ client = RetryableAioHttpClient(
18
+ retries=1,
19
+ refresh_token_func=None,
20
+ tracer_request_func=None,
21
+ fn_get_session=None, # No custom factory - SDK will create session
22
+ use_data_streaming=False,
23
+ access_token=None,
24
+ access_token_expiry_date=None,
25
+ )
26
+
27
+ async with client:
28
+ # Session should be created
29
+ assert client.session is not None
30
+ assert not client.session.closed
31
+ session_ref = client.session
32
+
33
+ # After exiting context, the internal session should be closed
34
+ assert session_ref.closed
35
+
36
+
37
+ @pytest.mark.asyncio
38
+ async def test_user_provided_session_is_not_closed_after_exit() -> None:
39
+ """Test that user-provided sessions are NOT closed when context exits"""
40
+ # User creates their own session
41
+ user_session = aiohttp.ClientSession()
42
+
43
+ try:
44
+ # Provide a factory that returns the user's session
45
+ # Since fn_get_session is provided, SDK will NOT close the session
46
+ client = RetryableAioHttpClient(
47
+ retries=1,
48
+ refresh_token_func=None,
49
+ tracer_request_func=None,
50
+ fn_get_session=lambda: user_session, # User provides a custom factory
51
+ use_data_streaming=False,
52
+ access_token=None,
53
+ access_token_expiry_date=None,
54
+ )
55
+
56
+ async with client:
57
+ # Session should be the user's session
58
+ assert client.session is user_session
59
+ assert not client.session.closed
60
+
61
+ # After exiting context, the user's session should still be open
62
+ # because fn_get_session was provided (caller manages session lifecycle)
63
+ assert not user_session.closed
64
+
65
+ finally:
66
+ # User closes their own session
67
+ await user_session.close()
68
+ assert user_session.closed
69
+
70
+
71
+ @pytest.mark.asyncio
72
+ async def test_multiple_clients_can_share_user_session() -> None:
73
+ """Test that multiple RetryableAioHttpClient instances can share the same user session"""
74
+ # User creates a persistent session
75
+ shared_session = aiohttp.ClientSession()
76
+
77
+ try:
78
+ # Multiple clients share the same session
79
+ async with RetryableAioHttpClient(
80
+ retries=1,
81
+ refresh_token_func=None,
82
+ tracer_request_func=None,
83
+ fn_get_session=lambda: shared_session,
84
+ use_data_streaming=False,
85
+ access_token=None,
86
+ access_token_expiry_date=None,
87
+ ) as client1:
88
+ assert client1.session is shared_session
89
+ assert not shared_session.closed
90
+
91
+ # Session should still be open after the first client exits
92
+ assert not shared_session.closed
93
+
94
+ # The second client can reuse the same session
95
+ async with RetryableAioHttpClient(
96
+ retries=1,
97
+ refresh_token_func=None,
98
+ tracer_request_func=None,
99
+ fn_get_session=lambda: shared_session,
100
+ use_data_streaming=False,
101
+ access_token=None,
102
+ access_token_expiry_date=None,
103
+ ) as client2:
104
+ assert client2.session is shared_session
105
+ assert not shared_session.closed
106
+
107
+ # Session should still be open after the second client exits
108
+ assert not shared_session.closed
109
+
110
+ finally:
111
+ # User closes the shared session when done
112
+ await shared_session.close()
113
+ assert shared_session.closed
114
+
115
+
116
+ @pytest.mark.asyncio
117
+ async def test_user_can_recreate_closed_session_via_factory() -> None:
118
+ """Test that a user's factory can be called multiple times if session gets closed"""
119
+ call_count = 0
120
+
121
+ def session_factory() -> aiohttp.ClientSession:
122
+ nonlocal call_count
123
+ call_count += 1
124
+ return aiohttp.ClientSession()
125
+
126
+ created_sessions = []
127
+
128
+ try:
129
+ # First client call
130
+ async with RetryableAioHttpClient(
131
+ retries=1,
132
+ refresh_token_func=None,
133
+ tracer_request_func=None,
134
+ fn_get_session=session_factory,
135
+ use_data_streaming=False,
136
+ access_token=None,
137
+ access_token_expiry_date=None,
138
+ ) as client1:
139
+ assert client1.session is not None
140
+ created_sessions.append(client1.session)
141
+ assert call_count == 1 # Factory called once in __aenter__
142
+
143
+ # SDK doesn't close session (caller provided fn_get_session)
144
+ assert created_sessions[0] is not None
145
+ assert not created_sessions[0].closed
146
+
147
+ # User could manually close and recreate via factory if needed
148
+ # (This demonstrates the pattern, though in practice the factory
149
+ # would handle closed session detection)
150
+
151
+ finally:
152
+ # Clean up all created sessions
153
+ for session in created_sessions:
154
+ if session is not None and not session.closed:
155
+ await session.close()
@@ -110,3 +110,46 @@ def test_clone_preserves_max_concurrent_requests() -> None:
110
110
  cloned_client = fhir_client.clone()
111
111
 
112
112
  assert cloned_client._max_concurrent_requests == 10
113
+
114
+
115
+ def test_use_http_session() -> None:
116
+ """Test that use_http_session sets the callable correctly"""
117
+ from aiohttp import ClientSession
118
+
119
+ def custom_session_factory() -> ClientSession:
120
+ return ClientSession()
121
+
122
+ fhir_client = FhirClient().url("http://example.com")
123
+
124
+ # Initially None
125
+ assert fhir_client._fn_create_http_session is None
126
+
127
+ # Set the callable
128
+ result = fhir_client.use_http_session(custom_session_factory)
129
+
130
+ # Returns self for chaining
131
+ assert result is fhir_client
132
+
133
+ # Callable is stored
134
+ assert fhir_client._fn_create_http_session is custom_session_factory
135
+
136
+ # Can set to None
137
+ fhir_client.use_http_session(None)
138
+ assert fhir_client._fn_create_http_session is None
139
+
140
+
141
+ def test_clone_preserves_fn_create_http_session() -> None:
142
+ """Test that clone() preserves the _fn_create_http_session callable"""
143
+ from aiohttp import ClientSession
144
+
145
+ def custom_session_factory() -> ClientSession:
146
+ return ClientSession()
147
+
148
+ fhir_client = FhirClient().url("http://example.com").use_http_session(custom_session_factory)
149
+
150
+ assert fhir_client._fn_create_http_session is custom_session_factory
151
+
152
+ # Clone and verify fn_create_http_session is preserved
153
+ cloned_client = fhir_client.clone()
154
+
155
+ assert cloned_client._fn_create_http_session is custom_session_factory