provide-foundation 0.0.0.dev2__py3-none-any.whl → 0.0.0.dev3__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.
Files changed (155) hide show
  1. provide/foundation/__init__.py +20 -20
  2. provide/foundation/archive/__init__.py +1 -1
  3. provide/foundation/archive/base.py +15 -14
  4. provide/foundation/archive/bzip2.py +40 -40
  5. provide/foundation/archive/gzip.py +42 -42
  6. provide/foundation/archive/operations.py +90 -91
  7. provide/foundation/archive/tar.py +33 -31
  8. provide/foundation/archive/zip.py +52 -50
  9. provide/foundation/asynctools/__init__.py +20 -0
  10. provide/foundation/asynctools/core.py +126 -0
  11. provide/foundation/cli/__init__.py +2 -2
  12. provide/foundation/cli/commands/deps.py +4 -4
  13. provide/foundation/cli/commands/logs/__init__.py +2 -2
  14. provide/foundation/cli/commands/logs/generate.py +2 -2
  15. provide/foundation/cli/commands/logs/query.py +3 -3
  16. provide/foundation/cli/commands/logs/send.py +2 -2
  17. provide/foundation/cli/commands/logs/tail.py +2 -2
  18. provide/foundation/cli/decorators.py +0 -1
  19. provide/foundation/cli/testing.py +0 -5
  20. provide/foundation/cli/utils.py +1 -2
  21. provide/foundation/config/__init__.py +19 -19
  22. provide/foundation/config/base.py +2 -2
  23. provide/foundation/config/converters.py +81 -83
  24. provide/foundation/config/defaults.py +1 -1
  25. provide/foundation/config/env.py +2 -1
  26. provide/foundation/config/loader.py +1 -1
  27. provide/foundation/config/sync.py +8 -6
  28. provide/foundation/config/types.py +5 -5
  29. provide/foundation/config/validators.py +4 -4
  30. provide/foundation/console/output.py +7 -7
  31. provide/foundation/context/core.py +19 -17
  32. provide/foundation/crypto/certificates/__init__.py +9 -5
  33. provide/foundation/crypto/certificates/base.py +2 -2
  34. provide/foundation/crypto/certificates/certificate.py +48 -19
  35. provide/foundation/crypto/certificates/factory.py +26 -18
  36. provide/foundation/crypto/certificates/generator.py +24 -23
  37. provide/foundation/crypto/certificates/loader.py +24 -16
  38. provide/foundation/crypto/certificates/operations.py +17 -10
  39. provide/foundation/crypto/certificates/trust.py +21 -21
  40. provide/foundation/env/__init__.py +28 -0
  41. provide/foundation/env/core.py +218 -0
  42. provide/foundation/errors/__init__.py +3 -2
  43. provide/foundation/errors/decorators.py +0 -3
  44. provide/foundation/errors/types.py +0 -1
  45. provide/foundation/eventsets/display.py +13 -14
  46. provide/foundation/eventsets/registry.py +61 -31
  47. provide/foundation/eventsets/resolver.py +50 -46
  48. provide/foundation/eventsets/sets/das.py +8 -8
  49. provide/foundation/eventsets/sets/database.py +14 -14
  50. provide/foundation/eventsets/sets/http.py +21 -21
  51. provide/foundation/eventsets/sets/llm.py +16 -16
  52. provide/foundation/eventsets/sets/task_queue.py +13 -13
  53. provide/foundation/eventsets/types.py +7 -7
  54. provide/foundation/file/directory.py +1 -1
  55. provide/foundation/file/lock.py +2 -3
  56. provide/foundation/hub/components.py +19 -21
  57. provide/foundation/hub/config.py +25 -19
  58. provide/foundation/hub/discovery.py +5 -4
  59. provide/foundation/hub/handlers.py +13 -5
  60. provide/foundation/hub/lifecycle.py +10 -9
  61. provide/foundation/hub/manager.py +3 -0
  62. provide/foundation/hub/processors.py +8 -3
  63. provide/foundation/integrations/__init__.py +1 -1
  64. provide/foundation/integrations/openobserve/client.py +2 -2
  65. provide/foundation/integrations/openobserve/commands.py +9 -9
  66. provide/foundation/integrations/openobserve/config.py +2 -2
  67. provide/foundation/integrations/openobserve/otlp.py +2 -2
  68. provide/foundation/integrations/openobserve/search.py +1 -2
  69. provide/foundation/integrations/openobserve/streaming.py +1 -1
  70. provide/foundation/logger/__init__.py +0 -1
  71. provide/foundation/logger/config/base.py +1 -1
  72. provide/foundation/logger/config/logging.py +19 -19
  73. provide/foundation/logger/config/telemetry.py +11 -13
  74. provide/foundation/logger/factories.py +2 -2
  75. provide/foundation/logger/processors/main.py +12 -10
  76. provide/foundation/logger/ratelimit/limiters.py +4 -4
  77. provide/foundation/logger/ratelimit/processor.py +1 -1
  78. provide/foundation/logger/setup/coordinator.py +38 -24
  79. provide/foundation/logger/setup/processors.py +3 -3
  80. provide/foundation/logger/setup/testing.py +14 -0
  81. provide/foundation/logger/trace.py +5 -5
  82. provide/foundation/metrics/__init__.py +1 -1
  83. provide/foundation/metrics/otel.py +3 -1
  84. provide/foundation/observability/__init__.py +1 -1
  85. provide/foundation/process/__init__.py +1 -1
  86. provide/foundation/process/exit.py +6 -5
  87. provide/foundation/process/lifecycle.py +41 -18
  88. provide/foundation/resilience/__init__.py +6 -5
  89. provide/foundation/resilience/circuit.py +32 -30
  90. provide/foundation/resilience/decorators.py +58 -42
  91. provide/foundation/resilience/fallback.py +55 -40
  92. provide/foundation/resilience/retry.py +67 -65
  93. provide/foundation/serialization/__init__.py +16 -0
  94. provide/foundation/serialization/core.py +70 -0
  95. provide/foundation/streams/config.py +8 -9
  96. provide/foundation/streams/console.py +3 -3
  97. provide/foundation/streams/core.py +2 -2
  98. provide/foundation/streams/file.py +1 -1
  99. provide/foundation/testing/__init__.py +22 -7
  100. provide/foundation/testing/archive/__init__.py +7 -7
  101. provide/foundation/testing/archive/fixtures.py +58 -54
  102. provide/foundation/testing/cli.py +3 -6
  103. provide/foundation/testing/common/__init__.py +13 -13
  104. provide/foundation/testing/common/fixtures.py +27 -30
  105. provide/foundation/testing/file/__init__.py +15 -15
  106. provide/foundation/testing/file/content_fixtures.py +65 -92
  107. provide/foundation/testing/file/directory_fixtures.py +19 -19
  108. provide/foundation/testing/file/fixtures.py +14 -17
  109. provide/foundation/testing/file/special_fixtures.py +34 -42
  110. provide/foundation/testing/logger.py +28 -23
  111. provide/foundation/testing/mocking/__init__.py +21 -21
  112. provide/foundation/testing/mocking/fixtures.py +80 -67
  113. provide/foundation/testing/process/__init__.py +23 -23
  114. provide/foundation/testing/process/async_fixtures.py +89 -80
  115. provide/foundation/testing/process/fixtures.py +11 -13
  116. provide/foundation/testing/process/subprocess_fixtures.py +41 -40
  117. provide/foundation/testing/threading/__init__.py +17 -17
  118. provide/foundation/testing/threading/basic_fixtures.py +21 -17
  119. provide/foundation/testing/threading/data_fixtures.py +18 -16
  120. provide/foundation/testing/threading/execution_fixtures.py +67 -52
  121. provide/foundation/testing/threading/fixtures.py +10 -14
  122. provide/foundation/testing/threading/sync_fixtures.py +21 -18
  123. provide/foundation/testing/time/__init__.py +11 -11
  124. provide/foundation/testing/time/fixtures.py +91 -79
  125. provide/foundation/testing/transport/__init__.py +9 -9
  126. provide/foundation/testing/transport/fixtures.py +54 -54
  127. provide/foundation/time/__init__.py +18 -0
  128. provide/foundation/time/core.py +63 -0
  129. provide/foundation/tools/__init__.py +2 -2
  130. provide/foundation/tools/base.py +68 -67
  131. provide/foundation/tools/cache.py +62 -69
  132. provide/foundation/tools/downloader.py +51 -56
  133. provide/foundation/tools/installer.py +51 -57
  134. provide/foundation/tools/registry.py +38 -45
  135. provide/foundation/tools/resolver.py +70 -68
  136. provide/foundation/tools/verifier.py +39 -50
  137. provide/foundation/tracer/spans.py +1 -13
  138. provide/foundation/transport/__init__.py +26 -33
  139. provide/foundation/transport/base.py +32 -30
  140. provide/foundation/transport/client.py +44 -49
  141. provide/foundation/transport/config.py +11 -13
  142. provide/foundation/transport/errors.py +13 -27
  143. provide/foundation/transport/http.py +69 -55
  144. provide/foundation/transport/middleware.py +86 -81
  145. provide/foundation/transport/registry.py +29 -27
  146. provide/foundation/transport/types.py +6 -6
  147. provide/foundation/utils/deps.py +3 -2
  148. provide/foundation/utils/parsing.py +7 -7
  149. {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/METADATA +2 -2
  150. provide_foundation-0.0.0.dev3.dist-info/RECORD +233 -0
  151. provide_foundation-0.0.0.dev2.dist-info/RECORD +0 -225
  152. {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/WHEEL +0 -0
  153. {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/entry_points.txt +0 -0
  154. {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/licenses/LICENSE +0 -0
  155. {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/top_level.txt +0 -0
@@ -5,10 +5,8 @@ Standardized mocking patterns and fixtures for the provide-io ecosystem.
5
5
  Reduces boilerplate and ensures consistent mocking across all tests.
6
6
  """
7
7
 
8
- from unittest.mock import Mock, MagicMock, AsyncMock, PropertyMock, patch, call, ANY
9
- from typing import Any, Callable
10
- from collections.abc import Generator
11
- import sys
8
+ from typing import Any
9
+ from unittest.mock import ANY, AsyncMock, MagicMock, Mock, PropertyMock, call, patch
12
10
 
13
11
  import pytest
14
12
 
@@ -17,18 +15,19 @@ import pytest
17
15
  def mock_factory():
18
16
  """
19
17
  Factory for creating configured mock objects.
20
-
18
+
21
19
  Returns:
22
20
  Function that creates mock objects with common configurations.
23
21
  """
24
- def _create_mock(name: str = None, **kwargs) -> Mock:
22
+
23
+ def _create_mock(name: str | None = None, **kwargs) -> Mock:
25
24
  """
26
25
  Create a mock with standard configuration.
27
-
26
+
28
27
  Args:
29
28
  name: Optional name for the mock
30
29
  **kwargs: Additional mock configuration
31
-
30
+
32
31
  Returns:
33
32
  Configured Mock object
34
33
  """
@@ -36,10 +35,10 @@ def mock_factory():
36
35
  "spec_set": True if "spec" in kwargs else False,
37
36
  }
38
37
  defaults.update(kwargs)
39
-
38
+
40
39
  mock = Mock(name=name, **defaults)
41
40
  return mock
42
-
41
+
43
42
  return _create_mock
44
43
 
45
44
 
@@ -47,23 +46,24 @@ def mock_factory():
47
46
  def magic_mock_factory():
48
47
  """
49
48
  Factory for creating MagicMock objects.
50
-
49
+
51
50
  Returns:
52
51
  Function that creates MagicMock objects with common configurations.
53
52
  """
54
- def _create_magic_mock(name: str = None, **kwargs) -> MagicMock:
53
+
54
+ def _create_magic_mock(name: str | None = None, **kwargs) -> MagicMock:
55
55
  """
56
56
  Create a MagicMock with standard configuration.
57
-
57
+
58
58
  Args:
59
59
  name: Optional name for the mock
60
60
  **kwargs: Additional mock configuration
61
-
61
+
62
62
  Returns:
63
63
  Configured MagicMock object
64
64
  """
65
65
  return MagicMock(name=name, **kwargs)
66
-
66
+
67
67
  return _create_magic_mock
68
68
 
69
69
 
@@ -71,20 +71,23 @@ def magic_mock_factory():
71
71
  def async_mock_factory():
72
72
  """
73
73
  Factory for creating AsyncMock objects.
74
-
74
+
75
75
  Returns:
76
76
  Function that creates AsyncMock objects with common configurations.
77
77
  """
78
- def _create_async_mock(name: str = None, return_value=None, side_effect=None, **kwargs) -> AsyncMock:
78
+
79
+ def _create_async_mock(
80
+ name: str | None = None, return_value: object = None, side_effect: object = None, **kwargs
81
+ ) -> AsyncMock:
79
82
  """
80
83
  Create an AsyncMock with standard configuration.
81
-
84
+
82
85
  Args:
83
86
  name: Optional name for the mock
84
87
  return_value: Return value for the async mock
85
88
  side_effect: Side effect for the async mock
86
89
  **kwargs: Additional mock configuration
87
-
90
+
88
91
  Returns:
89
92
  Configured AsyncMock object
90
93
  """
@@ -94,7 +97,7 @@ def async_mock_factory():
94
97
  if side_effect is not None:
95
98
  mock.side_effect = side_effect
96
99
  return mock
97
-
100
+
98
101
  return _create_async_mock
99
102
 
100
103
 
@@ -102,24 +105,29 @@ def async_mock_factory():
102
105
  def property_mock_factory():
103
106
  """
104
107
  Factory for creating PropertyMock objects.
105
-
108
+
106
109
  Returns:
107
110
  Function that creates PropertyMock objects.
108
111
  """
109
- def _create_property_mock(return_value=None, side_effect=None, **kwargs) -> PropertyMock:
112
+
113
+ def _create_property_mock(
114
+ return_value=None, side_effect=None, **kwargs
115
+ ) -> PropertyMock:
110
116
  """
111
117
  Create a PropertyMock.
112
-
118
+
113
119
  Args:
114
120
  return_value: Return value for the property
115
121
  side_effect: Side effect for the property
116
122
  **kwargs: Additional mock configuration
117
-
123
+
118
124
  Returns:
119
125
  Configured PropertyMock object
120
126
  """
121
- return PropertyMock(return_value=return_value, side_effect=side_effect, **kwargs)
122
-
127
+ return PropertyMock(
128
+ return_value=return_value, side_effect=side_effect, **kwargs
129
+ )
130
+
123
131
  return _create_property_mock
124
132
 
125
133
 
@@ -127,20 +135,20 @@ def property_mock_factory():
127
135
  def patch_fixture():
128
136
  """
129
137
  Fixture for patching objects with automatic cleanup.
130
-
138
+
131
139
  Returns:
132
140
  Function that patches objects and returns the mock.
133
141
  """
134
142
  patches = []
135
-
143
+
136
144
  def _patch(target: str, **kwargs) -> Mock:
137
145
  """
138
146
  Patch a target with automatic cleanup.
139
-
147
+
140
148
  Args:
141
149
  target: The target to patch (module.Class.attribute)
142
150
  **kwargs: Additional patch configuration
143
-
151
+
144
152
  Returns:
145
153
  The mock object
146
154
  """
@@ -148,9 +156,9 @@ def patch_fixture():
148
156
  mock = patcher.start()
149
157
  patches.append(patcher)
150
158
  return mock
151
-
159
+
152
160
  yield _patch
153
-
161
+
154
162
  # Cleanup all patches
155
163
  for patcher in patches:
156
164
  patcher.stop()
@@ -160,31 +168,32 @@ def patch_fixture():
160
168
  def patch_multiple_fixture():
161
169
  """
162
170
  Fixture for patching multiple objects at once.
163
-
171
+
164
172
  Returns:
165
173
  Function that patches multiple targets.
166
174
  """
167
175
  patches = []
168
-
176
+
169
177
  def _patch_multiple(target_module: str, **kwargs) -> dict[str, Mock]:
170
178
  """
171
179
  Patch multiple attributes in a module.
172
-
180
+
173
181
  Args:
174
182
  target_module: The module to patch in
175
183
  **kwargs: Mapping of attribute names to mock objects or DEFAULT
176
-
184
+
177
185
  Returns:
178
186
  Dict mapping attribute names to mock objects
179
187
  """
180
188
  from unittest.mock import patch as mock_patch
189
+
181
190
  patcher = mock_patch.multiple(target_module, **kwargs)
182
191
  mocks = patcher.start()
183
192
  patches.append(patcher)
184
193
  return mocks
185
-
194
+
186
195
  yield _patch_multiple
187
-
196
+
188
197
  # Cleanup all patches
189
198
  for patcher in patches:
190
199
  patcher.stop()
@@ -194,39 +203,41 @@ def patch_multiple_fixture():
194
203
  def auto_patch():
195
204
  """
196
205
  Context manager for automatic patching with cleanup.
197
-
206
+
198
207
  Returns:
199
208
  Patch context manager class.
200
209
  """
210
+
201
211
  class AutoPatch:
202
212
  def __init__(self):
203
213
  self.patches = []
204
-
214
+
205
215
  def object(self, target: Any, attribute: str, **kwargs) -> Mock:
206
216
  """Patch an object's attribute."""
207
217
  patcher = patch.object(target, attribute, **kwargs)
208
218
  mock = patcher.start()
209
219
  self.patches.append(patcher)
210
220
  return mock
211
-
221
+
212
222
  def dict(self, target: dict, values: dict, **kwargs) -> None:
213
223
  """Patch a dictionary."""
214
224
  patcher = patch.dict(target, values, **kwargs)
215
225
  patcher.start()
216
226
  self.patches.append(patcher)
217
-
227
+
218
228
  def env(self, **env_vars) -> None:
219
229
  """Patch environment variables."""
220
230
  import os
231
+
221
232
  patcher = patch.dict(os.environ, env_vars)
222
233
  patcher.start()
223
234
  self.patches.append(patcher)
224
-
235
+
225
236
  def cleanup(self):
226
237
  """Stop all patches."""
227
238
  for patcher in self.patches:
228
239
  patcher.stop()
229
-
240
+
230
241
  patcher = AutoPatch()
231
242
  yield patcher
232
243
  patcher.cleanup()
@@ -236,24 +247,24 @@ def auto_patch():
236
247
  def mock_open_fixture():
237
248
  """
238
249
  Fixture for mocking file operations.
239
-
250
+
240
251
  Returns:
241
252
  Function that creates a mock for open().
242
253
  """
243
254
  from unittest.mock import mock_open
244
-
255
+
245
256
  def _mock_open(read_data: str = None) -> Mock:
246
257
  """
247
258
  Create a mock for the open() builtin.
248
-
259
+
249
260
  Args:
250
261
  read_data: Optional data to return when reading
251
-
262
+
252
263
  Returns:
253
264
  Mock object for open()
254
265
  """
255
266
  return mock_open(read_data=read_data)
256
-
267
+
257
268
  return _mock_open
258
269
 
259
270
 
@@ -261,18 +272,19 @@ def mock_open_fixture():
261
272
  def spy_fixture():
262
273
  """
263
274
  Create a spy (mock that calls through to the original).
264
-
275
+
265
276
  Returns:
266
277
  Function that creates spy objects.
267
278
  """
279
+
268
280
  def _create_spy(obj: Any, method_name: str) -> Mock:
269
281
  """
270
282
  Create a spy on a method.
271
-
283
+
272
284
  Args:
273
285
  obj: The object to spy on
274
286
  method_name: The method name to spy on
275
-
287
+
276
288
  Returns:
277
289
  Mock that wraps the original method
278
290
  """
@@ -280,7 +292,7 @@ def spy_fixture():
280
292
  mock = Mock(wraps=original)
281
293
  setattr(obj, method_name, mock)
282
294
  return mock
283
-
295
+
284
296
  return _create_spy
285
297
 
286
298
 
@@ -288,14 +300,15 @@ def spy_fixture():
288
300
  def assert_mock_calls():
289
301
  """
290
302
  Helper for asserting mock calls with better error messages.
291
-
303
+
292
304
  Returns:
293
305
  Function for asserting mock calls.
294
306
  """
307
+
295
308
  def _assert_calls(mock: Mock, expected_calls: list, any_order: bool = False):
296
309
  """
297
310
  Assert that a mock was called with expected calls.
298
-
311
+
299
312
  Args:
300
313
  mock: The mock to check
301
314
  expected_calls: List of expected call objects
@@ -305,27 +318,27 @@ def assert_mock_calls():
305
318
  mock.assert_has_calls(expected_calls, any_order=True)
306
319
  else:
307
320
  mock.assert_has_calls(expected_calls)
308
-
321
+
309
322
  return _assert_calls
310
323
 
311
324
 
312
325
  # Re-export commonly used mock utilities
313
326
  __all__ = [
314
- "Mock",
315
- "MagicMock",
327
+ "ANY",
316
328
  "AsyncMock",
329
+ "MagicMock",
330
+ "Mock",
317
331
  "PropertyMock",
318
- "patch",
332
+ "assert_mock_calls",
333
+ "async_mock_factory",
334
+ "auto_patch",
319
335
  "call",
320
- "ANY",
321
- "mock_factory",
322
336
  "magic_mock_factory",
323
- "async_mock_factory",
324
- "property_mock_factory",
337
+ "mock_factory",
338
+ "mock_open_fixture",
339
+ "patch",
325
340
  "patch_fixture",
326
341
  "patch_multiple_fixture",
327
- "auto_patch",
328
- "mock_open_fixture",
342
+ "property_mock_factory",
329
343
  "spy_fixture",
330
- "assert_mock_calls",
331
- ]
344
+ ]
@@ -6,43 +6,43 @@ event loop management across any project that depends on provide.foundation.
6
6
  """
7
7
 
8
8
  from provide.foundation.testing.process.fixtures import (
9
- clean_event_loop,
10
- async_timeout,
11
- mock_async_process,
12
- async_stream_reader,
13
- event_loop_policy,
9
+ async_condition_waiter,
14
10
  async_context_manager,
11
+ async_gather_helper,
15
12
  async_iterator,
16
- async_queue,
17
13
  async_lock,
18
- mock_async_sleep,
19
- async_subprocess,
20
- async_gather_helper,
21
- async_task_group,
22
- async_condition_waiter,
23
14
  async_mock_server,
24
15
  async_pipeline,
16
+ async_queue,
25
17
  async_rate_limiter,
18
+ async_stream_reader,
19
+ async_subprocess,
20
+ async_task_group,
26
21
  async_test_client,
22
+ async_timeout,
23
+ clean_event_loop,
24
+ event_loop_policy,
25
+ mock_async_process,
26
+ mock_async_sleep,
27
27
  )
28
28
 
29
29
  __all__ = [
30
- "clean_event_loop",
31
- "async_timeout",
32
- "mock_async_process",
33
- "async_stream_reader",
34
- "event_loop_policy",
30
+ "async_condition_waiter",
35
31
  "async_context_manager",
32
+ "async_gather_helper",
36
33
  "async_iterator",
37
- "async_queue",
38
34
  "async_lock",
39
- "mock_async_sleep",
40
- "async_subprocess",
41
- "async_gather_helper",
42
- "async_task_group",
43
- "async_condition_waiter",
44
35
  "async_mock_server",
45
36
  "async_pipeline",
37
+ "async_queue",
46
38
  "async_rate_limiter",
39
+ "async_stream_reader",
40
+ "async_subprocess",
41
+ "async_task_group",
47
42
  "async_test_client",
48
- ]
43
+ "async_timeout",
44
+ "clean_event_loop",
45
+ "event_loop_policy",
46
+ "mock_async_process",
47
+ "mock_async_sleep",
48
+ ]