provide-foundation 0.0.0.dev0__py3-none-any.whl → 0.0.0.dev1__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 (92) hide show
  1. provide/foundation/__init__.py +12 -20
  2. provide/foundation/archive/__init__.py +23 -0
  3. provide/foundation/archive/base.py +70 -0
  4. provide/foundation/archive/bzip2.py +157 -0
  5. provide/foundation/archive/gzip.py +159 -0
  6. provide/foundation/archive/operations.py +336 -0
  7. provide/foundation/archive/tar.py +164 -0
  8. provide/foundation/archive/zip.py +203 -0
  9. provide/foundation/config/base.py +2 -2
  10. provide/foundation/config/sync.py +19 -4
  11. provide/foundation/core.py +1 -2
  12. provide/foundation/crypto/__init__.py +2 -0
  13. provide/foundation/crypto/certificates/__init__.py +34 -0
  14. provide/foundation/crypto/certificates/base.py +173 -0
  15. provide/foundation/crypto/certificates/certificate.py +290 -0
  16. provide/foundation/crypto/certificates/factory.py +213 -0
  17. provide/foundation/crypto/certificates/generator.py +138 -0
  18. provide/foundation/crypto/certificates/loader.py +130 -0
  19. provide/foundation/crypto/certificates/operations.py +198 -0
  20. provide/foundation/crypto/certificates/trust.py +107 -0
  21. provide/foundation/eventsets/__init__.py +0 -0
  22. provide/foundation/eventsets/display.py +84 -0
  23. provide/foundation/eventsets/registry.py +160 -0
  24. provide/foundation/eventsets/resolver.py +192 -0
  25. provide/foundation/eventsets/sets/das.py +128 -0
  26. provide/foundation/eventsets/sets/database.py +125 -0
  27. provide/foundation/eventsets/sets/http.py +153 -0
  28. provide/foundation/eventsets/sets/llm.py +139 -0
  29. provide/foundation/eventsets/sets/task_queue.py +107 -0
  30. provide/foundation/eventsets/types.py +70 -0
  31. provide/foundation/hub/components.py +7 -133
  32. provide/foundation/logger/__init__.py +3 -10
  33. provide/foundation/logger/config/logging.py +6 -6
  34. provide/foundation/logger/core.py +0 -2
  35. provide/foundation/logger/custom_processors.py +1 -0
  36. provide/foundation/logger/factories.py +11 -2
  37. provide/foundation/logger/processors/main.py +20 -84
  38. provide/foundation/logger/setup/__init__.py +5 -1
  39. provide/foundation/logger/setup/coordinator.py +75 -23
  40. provide/foundation/logger/setup/processors.py +2 -9
  41. provide/foundation/logger/trace.py +27 -0
  42. provide/foundation/metrics/otel.py +10 -10
  43. provide/foundation/process/lifecycle.py +82 -26
  44. provide/foundation/testing/__init__.py +77 -0
  45. provide/foundation/testing/archive/__init__.py +24 -0
  46. provide/foundation/testing/archive/fixtures.py +217 -0
  47. provide/foundation/testing/common/__init__.py +34 -0
  48. provide/foundation/testing/common/fixtures.py +263 -0
  49. provide/foundation/testing/file/__init__.py +40 -0
  50. provide/foundation/testing/file/fixtures.py +523 -0
  51. provide/foundation/testing/logger.py +41 -11
  52. provide/foundation/testing/mocking/__init__.py +46 -0
  53. provide/foundation/testing/mocking/fixtures.py +331 -0
  54. provide/foundation/testing/process/__init__.py +48 -0
  55. provide/foundation/testing/process/fixtures.py +577 -0
  56. provide/foundation/testing/threading/__init__.py +38 -0
  57. provide/foundation/testing/threading/fixtures.py +520 -0
  58. provide/foundation/testing/time/__init__.py +32 -0
  59. provide/foundation/testing/time/fixtures.py +409 -0
  60. provide/foundation/testing/transport/__init__.py +30 -0
  61. provide/foundation/testing/transport/fixtures.py +280 -0
  62. provide/foundation/tools/__init__.py +58 -0
  63. provide/foundation/tools/base.py +348 -0
  64. provide/foundation/tools/cache.py +266 -0
  65. provide/foundation/tools/downloader.py +213 -0
  66. provide/foundation/tools/installer.py +254 -0
  67. provide/foundation/tools/registry.py +223 -0
  68. provide/foundation/tools/resolver.py +321 -0
  69. provide/foundation/tools/verifier.py +186 -0
  70. provide/foundation/tracer/otel.py +7 -11
  71. provide/foundation/transport/__init__.py +155 -0
  72. provide/foundation/transport/base.py +171 -0
  73. provide/foundation/transport/client.py +266 -0
  74. provide/foundation/transport/config.py +209 -0
  75. provide/foundation/transport/errors.py +79 -0
  76. provide/foundation/transport/http.py +232 -0
  77. provide/foundation/transport/middleware.py +366 -0
  78. provide/foundation/transport/registry.py +167 -0
  79. provide/foundation/transport/types.py +45 -0
  80. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/METADATA +5 -28
  81. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/RECORD +85 -34
  82. provide/foundation/cli/commands/logs/generate_old.py +0 -569
  83. provide/foundation/crypto/certificates.py +0 -896
  84. provide/foundation/logger/emoji/__init__.py +0 -44
  85. provide/foundation/logger/emoji/matrix.py +0 -209
  86. provide/foundation/logger/emoji/sets.py +0 -458
  87. provide/foundation/logger/emoji/types.py +0 -56
  88. provide/foundation/logger/setup/emoji_resolver.py +0 -64
  89. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/WHEEL +0 -0
  90. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/entry_points.txt +0 -0
  91. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/licenses/LICENSE +0 -0
  92. {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,263 @@
1
+ """
2
+ Common Mock Objects and Fixtures.
3
+
4
+ Reusable mock objects for configuration, logging, and other common
5
+ testing scenarios across the provide-io ecosystem.
6
+ """
7
+
8
+ from unittest.mock import Mock, MagicMock, PropertyMock
9
+ from typing import Any
10
+
11
+ import pytest
12
+
13
+ from provide.foundation import TelemetryConfig
14
+ from provide.foundation.logger.config.logging import LoggingConfig
15
+
16
+
17
+ @pytest.fixture
18
+ def mock_http_config():
19
+ """
20
+ Standard HTTP configuration for testing.
21
+
22
+ Returns:
23
+ HTTPConfig with common test settings.
24
+ """
25
+ from provide.foundation.transport.config import HTTPConfig
26
+
27
+ return HTTPConfig(
28
+ timeout=30.0,
29
+ max_retries=3,
30
+ retry_backoff_factor=0.5,
31
+ verify_ssl=True,
32
+ pool_connections=10,
33
+ pool_maxsize=100,
34
+ follow_redirects=True,
35
+ http2=True,
36
+ max_redirects=5,
37
+ )
38
+
39
+
40
+ @pytest.fixture
41
+ def mock_logger():
42
+ """
43
+ Mock logger with captured method calls.
44
+
45
+ Returns:
46
+ Mock logger with debug, info, warning, error methods.
47
+ """
48
+ logger = Mock()
49
+ logger.debug = Mock()
50
+ logger.info = Mock()
51
+ logger.warning = Mock()
52
+ logger.error = Mock()
53
+ logger.exception = Mock()
54
+ logger.critical = Mock()
55
+
56
+ # Add common logger attributes
57
+ logger.name = "mock_logger"
58
+ logger.level = 10 # DEBUG level
59
+ logger.handlers = []
60
+ logger.disabled = False
61
+
62
+ # Add bind method for structlog compatibility
63
+ logger.bind = Mock(return_value=logger)
64
+ logger.unbind = Mock(return_value=logger)
65
+
66
+ return logger
67
+
68
+
69
+ @pytest.fixture
70
+ def mock_telemetry_config():
71
+ """
72
+ Standard telemetry configuration for testing.
73
+
74
+ Returns:
75
+ TelemetryConfig with debug logging enabled.
76
+ """
77
+ return TelemetryConfig(
78
+ logging=LoggingConfig(default_level="DEBUG"),
79
+ globally_disabled=False,
80
+ service_name="test_service",
81
+ service_version="1.0.0",
82
+ )
83
+
84
+
85
+ @pytest.fixture
86
+ def mock_config_source():
87
+ """
88
+ Mock configuration source for testing config loading.
89
+
90
+ Returns:
91
+ Mock that simulates a configuration source.
92
+ """
93
+ source = Mock()
94
+ source.load = Mock(return_value={"key": "value", "nested": {"key": "value"}})
95
+ source.exists = Mock(return_value=True)
96
+ source.reload = Mock()
97
+ source.watch = Mock()
98
+ source.priority = 100
99
+ source.name = "mock_source"
100
+
101
+ return source
102
+
103
+
104
+ @pytest.fixture
105
+ def mock_event_emitter():
106
+ """
107
+ Mock event emitter for testing event-driven components.
108
+
109
+ Returns:
110
+ Mock with emit, on, off methods.
111
+ """
112
+ emitter = Mock()
113
+ emitter.emit = Mock()
114
+ emitter.on = Mock()
115
+ emitter.off = Mock()
116
+ emitter.once = Mock()
117
+ emitter.listeners = Mock(return_value=[])
118
+ emitter.remove_all_listeners = Mock()
119
+
120
+ return emitter
121
+
122
+
123
+ @pytest.fixture
124
+ def mock_transport():
125
+ """
126
+ Mock transport for testing network operations.
127
+
128
+ Returns:
129
+ Mock transport with request/response methods.
130
+ """
131
+ transport = Mock()
132
+ transport.request = Mock(return_value={"status": 200, "data": {}})
133
+ transport.get = Mock(return_value={"status": 200, "data": {}})
134
+ transport.post = Mock(return_value={"status": 200, "data": {}})
135
+ transport.put = Mock(return_value={"status": 200, "data": {}})
136
+ transport.delete = Mock(return_value={"status": 204})
137
+ transport.close = Mock()
138
+
139
+ return transport
140
+
141
+
142
+ @pytest.fixture
143
+ def mock_metrics_collector():
144
+ """
145
+ Mock metrics collector for testing instrumentation.
146
+
147
+ Returns:
148
+ Mock with common metrics methods.
149
+ """
150
+ collector = Mock()
151
+ collector.increment = Mock()
152
+ collector.decrement = Mock()
153
+ collector.gauge = Mock()
154
+ collector.histogram = Mock()
155
+ collector.timer = Mock()
156
+ collector.flush = Mock()
157
+
158
+ # Add context manager support for timing
159
+ timer_cm = Mock()
160
+ timer_cm.__enter__ = Mock(return_value=timer_cm)
161
+ timer_cm.__exit__ = Mock(return_value=None)
162
+ collector.timer.return_value = timer_cm
163
+
164
+ return collector
165
+
166
+
167
+ @pytest.fixture
168
+ def mock_cache():
169
+ """
170
+ Mock cache for testing caching behavior.
171
+
172
+ Returns:
173
+ Mock with get, set, delete, clear methods.
174
+ """
175
+ cache_data = {}
176
+
177
+ cache = Mock()
178
+ cache.get = Mock(side_effect=lambda k, default=None: cache_data.get(k, default))
179
+ cache.set = Mock(side_effect=lambda k, v, ttl=None: cache_data.update({k: v}))
180
+ cache.delete = Mock(side_effect=lambda k: cache_data.pop(k, None))
181
+ cache.clear = Mock(side_effect=cache_data.clear)
182
+ cache.exists = Mock(side_effect=lambda k: k in cache_data)
183
+ cache.keys = Mock(return_value=list(cache_data.keys()))
184
+
185
+ # Store reference to data for test assertions
186
+ cache._data = cache_data
187
+
188
+ return cache
189
+
190
+
191
+ @pytest.fixture
192
+ def mock_database():
193
+ """
194
+ Mock database connection for testing.
195
+
196
+ Returns:
197
+ Mock with execute, fetch, commit, rollback methods.
198
+ """
199
+ db = Mock()
200
+ db.execute = Mock(return_value=Mock(rowcount=1))
201
+ db.fetch = Mock(return_value=[])
202
+ db.fetchone = Mock(return_value=None)
203
+ db.fetchall = Mock(return_value=[])
204
+ db.commit = Mock()
205
+ db.rollback = Mock()
206
+ db.close = Mock()
207
+ db.is_connected = PropertyMock(return_value=True)
208
+
209
+ # Add context manager support
210
+ db.__enter__ = Mock(return_value=db)
211
+ db.__exit__ = Mock(return_value=None)
212
+
213
+ return db
214
+
215
+
216
+ @pytest.fixture
217
+ def mock_file_system():
218
+ """
219
+ Mock file system operations.
220
+
221
+ Returns:
222
+ Mock with read, write, exists, delete methods.
223
+ """
224
+ fs = Mock()
225
+ fs.read = Mock(return_value=b"content")
226
+ fs.write = Mock()
227
+ fs.exists = Mock(return_value=True)
228
+ fs.delete = Mock()
229
+ fs.mkdir = Mock()
230
+ fs.rmdir = Mock()
231
+ fs.list = Mock(return_value=[])
232
+ fs.stat = Mock(return_value=Mock(st_size=1024, st_mtime=0))
233
+
234
+ return fs
235
+
236
+
237
+ @pytest.fixture
238
+ def mock_subprocess():
239
+ """
240
+ Mock subprocess for testing command execution.
241
+
242
+ Returns:
243
+ Mock with run, Popen methods.
244
+ """
245
+ subprocess = Mock()
246
+
247
+ # Mock run method
248
+ result = Mock()
249
+ result.returncode = 0
250
+ result.stdout = "output"
251
+ result.stderr = ""
252
+ subprocess.run = Mock(return_value=result)
253
+
254
+ # Mock Popen
255
+ process = Mock()
256
+ process.communicate = Mock(return_value=("output", ""))
257
+ process.returncode = 0
258
+ process.pid = 12345
259
+ process.poll = Mock(return_value=0)
260
+ process.wait = Mock(return_value=0)
261
+ subprocess.Popen = Mock(return_value=process)
262
+
263
+ return subprocess
@@ -0,0 +1,40 @@
1
+ """
2
+ File testing fixtures for the provide-io ecosystem.
3
+
4
+ Standard fixtures for file and directory operations that can be used
5
+ across any project that depends on provide.foundation.
6
+ """
7
+
8
+ from provide.foundation.testing.file.fixtures import (
9
+ temp_directory,
10
+ test_files_structure,
11
+ temp_file,
12
+ binary_file,
13
+ nested_directory_structure,
14
+ empty_directory,
15
+ readonly_file,
16
+ temp_named_file,
17
+ temp_file_with_content,
18
+ temp_binary_file,
19
+ temp_csv_file,
20
+ temp_json_file,
21
+ temp_symlink,
22
+ temp_executable_file,
23
+ )
24
+
25
+ __all__ = [
26
+ "temp_directory",
27
+ "test_files_structure",
28
+ "temp_file",
29
+ "binary_file",
30
+ "nested_directory_structure",
31
+ "empty_directory",
32
+ "readonly_file",
33
+ "temp_named_file",
34
+ "temp_file_with_content",
35
+ "temp_binary_file",
36
+ "temp_csv_file",
37
+ "temp_json_file",
38
+ "temp_symlink",
39
+ "temp_executable_file",
40
+ ]