orionis 0.444.0__py3-none-any.whl → 0.445.0__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.
- orionis/foundation/application.py +0 -2
- orionis/metadata/framework.py +1 -1
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/METADATA +1 -1
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/RECORD +9 -20
- tests/example/test_example.py +163 -173
- orionis/foundation/providers/path_resolver_provider.py +0 -43
- orionis/services/paths/__init__.py +0 -0
- orionis/services/paths/contracts/__init__.py +0 -0
- orionis/services/paths/contracts/resolver.py +0 -51
- orionis/services/paths/exceptions/__init__.py +0 -7
- orionis/services/paths/exceptions/exception.py +0 -19
- orionis/services/paths/exceptions/file.py +0 -19
- orionis/services/paths/resolver.py +0 -95
- orionis/support/facades/path_resolver.py +0 -15
- tests/services/path/__init__.py +0 -0
- tests/services/path/test_services_resolver.py +0 -112
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/WHEEL +0 -0
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/top_level.txt +0 -0
- {orionis-0.444.0.dist-info → orionis-0.445.0.dist-info}/zip-safe +0 -0
|
@@ -174,7 +174,6 @@ class Application(Container, IApplication):
|
|
|
174
174
|
# Import core framework providers
|
|
175
175
|
from orionis.foundation.providers.console_provider import ConsoleProvider
|
|
176
176
|
from orionis.foundation.providers.dumper_provider import DumperProvider
|
|
177
|
-
from orionis.foundation.providers.path_resolver_provider import PathResolverProvider
|
|
178
177
|
from orionis.foundation.providers.progress_bar_provider import ProgressBarProvider
|
|
179
178
|
from orionis.foundation.providers.workers_provider import WorkersProvider
|
|
180
179
|
from orionis.foundation.providers.testing_provider import TestingProvider
|
|
@@ -183,7 +182,6 @@ class Application(Container, IApplication):
|
|
|
183
182
|
core_providers = [
|
|
184
183
|
ConsoleProvider,
|
|
185
184
|
DumperProvider,
|
|
186
|
-
PathResolverProvider,
|
|
187
185
|
ProgressBarProvider,
|
|
188
186
|
WorkersProvider,
|
|
189
187
|
LoggerProvider,
|
orionis/metadata/framework.py
CHANGED
|
@@ -68,7 +68,7 @@ orionis/container/validators/is_subclass.py,sha256=4sBaGLoRs8nUhuWjlP0VJqyTwVHYq
|
|
|
68
68
|
orionis/container/validators/is_valid_alias.py,sha256=4uAYcq8xov7jZbXnpKpjNkxcZtlTNnL5RRctVPMwJes,1424
|
|
69
69
|
orionis/container/validators/lifetime.py,sha256=IQ43fDNrxYHMlZH2zlYDJnlkLO_eS4U7Fs3UJgQBidI,1844
|
|
70
70
|
orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
71
|
-
orionis/foundation/application.py,sha256=
|
|
71
|
+
orionis/foundation/application.py,sha256=ErkfS6AlC817vBmVDbx_UVYmkaABuEqZCBCrkDGNmzo,76653
|
|
72
72
|
orionis/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
orionis/foundation/config/startup.py,sha256=vbzduprRCNyYeR2nnMaqc1uKXw6PTzAY2jVfXNQKN8I,9691
|
|
74
74
|
orionis/foundation/config/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -174,12 +174,11 @@ orionis/foundation/providers/console_provider.py,sha256=wsv0RjoYU9MatC1ZRBAtV9iC
|
|
|
174
174
|
orionis/foundation/providers/dumper_provider.py,sha256=d0k9yKVfwf40W4If0_rF09odLDXFA1w9jxU1MvZvCbo,1498
|
|
175
175
|
orionis/foundation/providers/inspirational_provider.py,sha256=ZIsuEq2Sif7C1b1hYC7_mEBd0kGwd8KWd-fHyyd6Qs4,2298
|
|
176
176
|
orionis/foundation/providers/logger_provider.py,sha256=PvwMxP5TKmn9DP8H8nJfyr16XgiJaGHyxPSMOpFgv84,1448
|
|
177
|
-
orionis/foundation/providers/path_resolver_provider.py,sha256=s44Mg68RsUNPlilQlXMBE7onVexa7kyDmVQmci1JL4g,1342
|
|
178
177
|
orionis/foundation/providers/progress_bar_provider.py,sha256=P__zpCyC29WCwErYGbh5dgcMRxw3XYmHzaUkzms9vPM,1345
|
|
179
178
|
orionis/foundation/providers/testing_provider.py,sha256=fSZfwKnScTxGlGrcEPReGIiOPs8XkoEaNNARN1wC6LU,2939
|
|
180
179
|
orionis/foundation/providers/workers_provider.py,sha256=YMRLdq_YQnR1unnoYvDpYQZbLli04f0CckuR6Q--wKg,1379
|
|
181
180
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
182
|
-
orionis/metadata/framework.py,sha256=
|
|
181
|
+
orionis/metadata/framework.py,sha256=192rDsW-nKtJVGcJdvakEiGySD3zpYemH8-LYFk5spQ,4088
|
|
183
182
|
orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
|
|
184
183
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
185
184
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -260,13 +259,6 @@ orionis/services/log/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
260
259
|
orionis/services/log/handlers/filename.py,sha256=XKkq4Gq7N2m8F3xtyUIevTQLMaYSLJ3wC04Irs45VcE,2481
|
|
261
260
|
orionis/services/log/handlers/size_rotating.py,sha256=SLg7r-XW1NWyVxN8wJxeI8jhypzdXw_jq2zg5uy3iaQ,1131
|
|
262
261
|
orionis/services/log/handlers/timed_rotating.py,sha256=UJicPwHcIVl2FPRPjuiKwH3-zuiPG1YV7UYLLMPm4To,1128
|
|
263
|
-
orionis/services/paths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
264
|
-
orionis/services/paths/resolver.py,sha256=6XPQ4D2P-8teg_lJAC4Ju_bAxbkb5rjoR3D-CaNmYAQ,3097
|
|
265
|
-
orionis/services/paths/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
266
|
-
orionis/services/paths/contracts/resolver.py,sha256=3RFi2mlwqSwknYvZCnyKVcTIUEhb7k21oTs9gSP3m3U,1144
|
|
267
|
-
orionis/services/paths/exceptions/__init__.py,sha256=r5b4D4XWNK07zLtqaXBk_PNYszScqbp_8kUN37cOk4E,184
|
|
268
|
-
orionis/services/paths/exceptions/exception.py,sha256=cK-TbUT02X2lvbAP4yFdfHx4S45wBOcYl3_tiWd67UM,472
|
|
269
|
-
orionis/services/paths/exceptions/file.py,sha256=bsK0QoXwRFyDeHvITxwmgaBuwiO2eoRUhRzNizmX1No,475
|
|
270
262
|
orionis/services/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
271
263
|
orionis/services/system/imports.py,sha256=aSXG9879ur91d6OsqV2DUYWmmwbwFHX8CHb99cPfFcU,7057
|
|
272
264
|
orionis/services/system/workers.py,sha256=EfGxU_w42xRnZ1yslsui3wVG8pfe__V3GYGEIyo8JxQ,3144
|
|
@@ -283,7 +275,6 @@ orionis/support/facades/console.py,sha256=OvxQ-r8PsPocJTaIUftmJnnr4SuONHQWYFz2_r
|
|
|
283
275
|
orionis/support/facades/dumper.py,sha256=XAHJTXrMjPchGQMIAU0hlcUjMZQK_ogrE0voRm2HdI8,434
|
|
284
276
|
orionis/support/facades/inspire.py,sha256=m2UbKXyggxASd0HTRT5M-mJ0FvMP_NIJ0lW8HTQMi4M,759
|
|
285
277
|
orionis/support/facades/logger.py,sha256=2EbSbJDSyKFUQmZUpoMsc5704Mzj2Skehx_9UpDluhc,450
|
|
286
|
-
orionis/support/facades/path_resolver.py,sha256=lRLbu69i8PzM-I53gzXroHIurxzyFdssNWOYMjPgqco,442
|
|
287
278
|
orionis/support/facades/progress_bar.py,sha256=NOCwAV873GptedgySMZpM_A_DoM-UQrMg2kDHpS6zi8,423
|
|
288
279
|
orionis/support/facades/testing.py,sha256=FJy7bnDiNHMe7jutARELHom6umDxlLVMMOj6aLm0Vak,490
|
|
289
280
|
orionis/support/facades/workers.py,sha256=DJ_mSnD4budFBrPGf-epVYrSQ1AzDcJ82db0QmNTAyU,479
|
|
@@ -352,7 +343,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
|
|
|
352
343
|
orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
|
|
353
344
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
354
345
|
orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
|
|
355
|
-
orionis-0.
|
|
346
|
+
orionis-0.445.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
356
347
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
357
348
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
358
349
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -386,7 +377,7 @@ tests/container/validators/test_is_subclass.py,sha256=0Uc8uIR69ZX7G5Nrex0LMQXrue
|
|
|
386
377
|
tests/container/validators/test_is_valid_alias.py,sha256=NA9QbIEh7n2_0GeVTMCppZG4_3ya4QrcvGI_lw1iJA8,5658
|
|
387
378
|
tests/container/validators/test_lifetime.py,sha256=5PequjXAcIcp0Q4TIki7THSU31XftGpI0u1mVGqHmpU,4692
|
|
388
379
|
tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
389
|
-
tests/example/test_example.py,sha256=
|
|
380
|
+
tests/example/test_example.py,sha256=W6lA0_uV6bNm7JZ39rHZn30LHkdq_ddrUO6T1K2raZ4,27104
|
|
390
381
|
tests/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
391
382
|
tests/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
392
383
|
tests/foundation/config/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -464,8 +455,6 @@ tests/services/introspection/reflection/mock/__init__.py,sha256=47DEQpj8HBSa-_TI
|
|
|
464
455
|
tests/services/introspection/reflection/mock/fake_reflect_instance.py,sha256=iMf_yKgk0Y91XUHhRcl2qw7Z83QeNspvLi_tl4Dp-rI,28032
|
|
465
456
|
tests/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
466
457
|
tests/services/log/test_log.py,sha256=fCI2gX9-YN1z-xPMwIlggUFHeBlqfUajQoyQu4dmao0,2868
|
|
467
|
-
tests/services/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
468
|
-
tests/services/path/test_services_resolver.py,sha256=aWSSFgV_D10t3llUeCWEBB1mF3dWrZbFn5XbJy2sQME,3903
|
|
469
458
|
tests/services/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
470
459
|
tests/services/system/test_services_system_imports.py,sha256=jbtIQkw_4DI6x2E-4Lg3evnLAgCgDIBWE63LdJTLkxc,7507
|
|
471
460
|
tests/services/system/test_services_system_workers.py,sha256=wITbpJHKW_OXqTaFeteNRFuw5Q3_7d9lWNJnFE2r6to,5052
|
|
@@ -498,8 +487,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
498
487
|
tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
|
|
499
488
|
tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
500
489
|
tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
|
|
501
|
-
orionis-0.
|
|
502
|
-
orionis-0.
|
|
503
|
-
orionis-0.
|
|
504
|
-
orionis-0.
|
|
505
|
-
orionis-0.
|
|
490
|
+
orionis-0.445.0.dist-info/METADATA,sha256=7gz5KAzfzBJKnWCXoyTfW7Izx8pbJGm9SR-LDA3F4rQ,4772
|
|
491
|
+
orionis-0.445.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
492
|
+
orionis-0.445.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
493
|
+
orionis-0.445.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
494
|
+
orionis-0.445.0.dist-info/RECORD,,
|
tests/example/test_example.py
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Orionis Framework Test Examples
|
|
3
|
-
===============================
|
|
4
|
-
|
|
5
|
-
This module contains comprehensive test examples demonstrating the capabilities
|
|
6
|
-
of the Orionis testing framework, including both synchronous and asynchronous
|
|
7
|
-
testing patterns with dependency injection.
|
|
8
|
-
|
|
9
|
-
Examples:
|
|
10
|
-
--------
|
|
11
|
-
Run synchronous tests:
|
|
12
|
-
>>> from tests.example.test_example import TestSynchronousExample
|
|
13
|
-
>>> test = TestSynchronousExample()
|
|
14
|
-
>>> test.setUp()
|
|
15
|
-
>>> test.testBasicAssertions()
|
|
16
|
-
|
|
17
|
-
Run asynchronous tests:
|
|
18
|
-
>>> from tests.example.test_example import TestAsynchronousExample
|
|
19
|
-
>>> test = TestAsynchronousExample()
|
|
20
|
-
>>> await test.asyncSetUp()
|
|
21
|
-
>>> await test.testAsyncBasicOperations()
|
|
22
|
-
|
|
23
|
-
Notes:
|
|
24
|
-
-----
|
|
25
|
-
These examples showcase:
|
|
26
|
-
- Dependency injection patterns
|
|
27
|
-
- Path resolution services
|
|
28
|
-
- Container integration
|
|
29
|
-
- Error handling strategies
|
|
30
|
-
- Data validation techniques
|
|
31
|
-
- Concurrent operations
|
|
32
|
-
- Async/await patterns
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
1
|
import asyncio
|
|
36
2
|
import time
|
|
37
3
|
from typing import Dict, List, Any
|
|
38
4
|
from orionis.foundation.application import Application
|
|
39
|
-
from orionis.services.
|
|
5
|
+
from orionis.services.system.contracts.workers import IWorkers
|
|
40
6
|
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
41
7
|
from orionis.test.cases.synchronous import SyncTestCase
|
|
42
8
|
|
|
@@ -48,44 +14,6 @@ class TestSynchronousExample(SyncTestCase):
|
|
|
48
14
|
path resolution, container usage, and error handling in a synchronous context.
|
|
49
15
|
The tests demonstrate best practices for writing maintainable and reliable
|
|
50
16
|
test cases within the Orionis framework.
|
|
51
|
-
|
|
52
|
-
Attributes
|
|
53
|
-
----------
|
|
54
|
-
test_data : Dict[str, Any]
|
|
55
|
-
Test data dictionary containing sample files and expected values
|
|
56
|
-
for use across multiple test methods.
|
|
57
|
-
|
|
58
|
-
Methods
|
|
59
|
-
-------
|
|
60
|
-
setUp()
|
|
61
|
-
Initialize test environment before each test method execution.
|
|
62
|
-
tearDown()
|
|
63
|
-
Clean up resources after each test method completion.
|
|
64
|
-
testBasicAssertions()
|
|
65
|
-
Validate basic assertion functionality and patterns.
|
|
66
|
-
testPathResolution(paths)
|
|
67
|
-
Test path resolution service functionality with dependency injection.
|
|
68
|
-
testContainerIntegration(container)
|
|
69
|
-
Validate container dependency injection capabilities.
|
|
70
|
-
testErrorHandling()
|
|
71
|
-
Test error handling and exception management patterns.
|
|
72
|
-
testDataValidation()
|
|
73
|
-
Validate data validation and complex assertion patterns.
|
|
74
|
-
|
|
75
|
-
Examples
|
|
76
|
-
--------
|
|
77
|
-
Basic usage:
|
|
78
|
-
>>> test = TestSynchronousExample()
|
|
79
|
-
>>> test.setUp()
|
|
80
|
-
>>> test.testBasicAssertions()
|
|
81
|
-
>>> test.tearDown()
|
|
82
|
-
|
|
83
|
-
With dependency injection:
|
|
84
|
-
>>> test = TestSynchronousExample()
|
|
85
|
-
>>> test.setUp()
|
|
86
|
-
>>> # Path resolver will be injected automatically
|
|
87
|
-
>>> test.testPathResolution(resolver_instance)
|
|
88
|
-
>>> test.tearDown()
|
|
89
17
|
"""
|
|
90
18
|
|
|
91
19
|
def setUp(self) -> None:
|
|
@@ -156,90 +84,112 @@ class TestSynchronousExample(SyncTestCase):
|
|
|
156
84
|
"Unexpected value found in container"
|
|
157
85
|
)
|
|
158
86
|
|
|
159
|
-
def
|
|
87
|
+
def testMaxWorkers(self, worker: IWorkers) -> None:
|
|
160
88
|
"""
|
|
161
|
-
Test
|
|
89
|
+
Test worker service functionality with dependency injection.
|
|
162
90
|
|
|
163
|
-
Validates the
|
|
164
|
-
|
|
165
|
-
injection
|
|
91
|
+
Validates the worker service's ability to calculate the maximum number
|
|
92
|
+
of available workers in the system. This method demonstrates dependency
|
|
93
|
+
injection capabilities with the IWorkers service and ensures proper
|
|
94
|
+
worker count calculation functionality.
|
|
166
95
|
|
|
167
96
|
Parameters
|
|
168
97
|
----------
|
|
169
|
-
|
|
170
|
-
Injected
|
|
171
|
-
|
|
172
|
-
based on
|
|
98
|
+
worker : IWorkers
|
|
99
|
+
Injected worker service instance for testing worker calculation
|
|
100
|
+
capabilities. The service provides methods for determining optimal
|
|
101
|
+
worker counts based on system resources.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
None
|
|
106
|
+
This test method does not return any value. It performs assertions
|
|
107
|
+
to validate the worker service functionality.
|
|
173
108
|
|
|
174
109
|
Tests
|
|
175
110
|
-----
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
111
|
+
- Worker service instance validation
|
|
112
|
+
- Worker count calculation functionality
|
|
113
|
+
- Worker count positive value validation
|
|
114
|
+
- Service method execution through dependency injection
|
|
180
115
|
|
|
181
116
|
Raises
|
|
182
117
|
------
|
|
183
118
|
AssertionError
|
|
184
|
-
If
|
|
119
|
+
If worker count calculation fails, returns invalid values, or
|
|
120
|
+
the calculated worker count is not greater than zero.
|
|
185
121
|
"""
|
|
186
|
-
# Test relative path resolution
|
|
187
|
-
relative_path = paths.relativePath(self.test_data["sample_file"])
|
|
188
|
-
path_string = relative_path.toString()
|
|
189
122
|
|
|
190
|
-
#
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"Path should contain expected directory structure"
|
|
123
|
+
# Calculate maximum available workers using the injected service
|
|
124
|
+
max_workers = worker.calculate()
|
|
125
|
+
|
|
126
|
+
# Validate that worker count is greater than zero
|
|
127
|
+
self.assertGreater(
|
|
128
|
+
max_workers,
|
|
129
|
+
0,
|
|
130
|
+
"Worker count should be greater than zero"
|
|
199
131
|
)
|
|
200
132
|
|
|
201
133
|
def testContainerIntegration(self, container: Application) -> None:
|
|
202
134
|
"""
|
|
203
135
|
Test container dependency injection functionality.
|
|
204
136
|
|
|
205
|
-
Validates the container's ability to resolve services and manage
|
|
206
|
-
dependencies. This method demonstrates the dependency injection
|
|
207
|
-
capabilities of the Orionis application container
|
|
137
|
+
Validates the application container's ability to resolve services and manage
|
|
138
|
+
dependencies correctly. This method demonstrates the dependency injection
|
|
139
|
+
capabilities of the Orionis application container, including service
|
|
140
|
+
registration, resolution, and lifecycle management. The test ensures that
|
|
141
|
+
the container can successfully instantiate and provide service instances
|
|
142
|
+
when requested through the dependency injection mechanism.
|
|
208
143
|
|
|
209
144
|
Parameters
|
|
210
145
|
----------
|
|
211
146
|
container : Application
|
|
212
147
|
Injected application container instance for testing dependency
|
|
213
|
-
injection capabilities. The container manages service resolution
|
|
214
|
-
and
|
|
148
|
+
injection capabilities. The container manages service resolution,
|
|
149
|
+
dependency lifecycle, and provides access to registered services
|
|
150
|
+
throughout the application.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
None
|
|
155
|
+
This test method does not return any value. It performs assertions
|
|
156
|
+
to validate the container's dependency injection functionality.
|
|
215
157
|
|
|
216
158
|
Tests
|
|
217
159
|
-----
|
|
218
|
-
- Container instance validation
|
|
219
|
-
- Service resolution from container
|
|
220
|
-
- Service functionality validation through container
|
|
221
|
-
- Dependency lifecycle management
|
|
160
|
+
- Container instance validation and null checking
|
|
161
|
+
- Service resolution from container using interface contracts
|
|
162
|
+
- Service functionality validation through container-resolved instances
|
|
163
|
+
- Dependency lifecycle management and proper instantiation
|
|
164
|
+
- Interface-to-implementation mapping verification
|
|
222
165
|
|
|
223
166
|
Raises
|
|
224
167
|
------
|
|
225
168
|
AssertionError
|
|
226
|
-
If container operations fail
|
|
169
|
+
If container operations fail, services cannot be resolved, or
|
|
170
|
+
the container instance is invalid or None.
|
|
171
|
+
|
|
172
|
+
Notes
|
|
173
|
+
-----
|
|
174
|
+
This test validates the core dependency injection functionality that
|
|
175
|
+
is essential for the Orionis framework's service architecture. The
|
|
176
|
+
container must be able to resolve services using their interface
|
|
177
|
+
contracts and provide properly configured instances.
|
|
227
178
|
"""
|
|
228
|
-
|
|
179
|
+
|
|
180
|
+
# Validate that the injected container instance is not None
|
|
181
|
+
# This ensures the dependency injection framework is working correctly
|
|
229
182
|
self.assertIsNotNone(container, "Container instance should not be None")
|
|
230
183
|
|
|
231
|
-
#
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
path_resolver,
|
|
235
|
-
"Service resolution should return valid instance"
|
|
236
|
-
)
|
|
184
|
+
# Attempt to resolve the IWorkers service from the container
|
|
185
|
+
# This tests the container's ability to map interfaces to implementations
|
|
186
|
+
workers: IWorkers = container.make(IWorkers)
|
|
237
187
|
|
|
238
|
-
#
|
|
239
|
-
|
|
188
|
+
# Verify that the service resolution was successful
|
|
189
|
+
# The container should return a valid instance implementing IWorkers
|
|
240
190
|
self.assertIsNotNone(
|
|
241
|
-
|
|
242
|
-
"Service
|
|
191
|
+
workers,
|
|
192
|
+
"Service resolution should return valid instance"
|
|
243
193
|
)
|
|
244
194
|
|
|
245
195
|
def testErrorHandling(self) -> None:
|
|
@@ -436,54 +386,50 @@ class TestAsynchronousExample(AsyncTestCase):
|
|
|
436
386
|
"Async sleep duration should not exceed maximum time tolerance"
|
|
437
387
|
)
|
|
438
388
|
|
|
439
|
-
async def
|
|
389
|
+
async def testAsyncMaxWorkers(self, worker: IWorkers) -> None:
|
|
440
390
|
"""
|
|
441
|
-
Test async
|
|
391
|
+
Test async worker service functionality with dependency injection.
|
|
442
392
|
|
|
443
|
-
Validates async
|
|
444
|
-
operations and testing
|
|
393
|
+
Validates async worker operations by simulating async I/O
|
|
394
|
+
operations and testing worker calculation in an asynchronous context.
|
|
445
395
|
This method demonstrates async dependency injection patterns.
|
|
446
396
|
|
|
447
397
|
Parameters
|
|
448
398
|
----------
|
|
449
|
-
|
|
450
|
-
Injected
|
|
399
|
+
worker : IWorkers
|
|
400
|
+
Injected worker service instance for async worker operations.
|
|
451
401
|
This parameter is automatically injected by the async testing framework.
|
|
452
402
|
|
|
453
403
|
Tests
|
|
454
404
|
-----
|
|
455
|
-
- Async
|
|
456
|
-
-
|
|
457
|
-
-
|
|
405
|
+
- Async worker calculation with simulated I/O delay
|
|
406
|
+
- Worker count validation in async context
|
|
407
|
+
- Worker validation in async operations
|
|
458
408
|
- Async service method execution
|
|
459
409
|
|
|
460
410
|
Raises
|
|
461
411
|
------
|
|
462
412
|
AssertionError
|
|
463
|
-
If async
|
|
413
|
+
If async worker calculation fails or returns unexpected results.
|
|
464
414
|
"""
|
|
465
|
-
async def
|
|
415
|
+
async def calculate_workers_async() -> int:
|
|
466
416
|
"""
|
|
467
|
-
Simulate async
|
|
468
|
-
|
|
469
|
-
Parameters
|
|
470
|
-
----------
|
|
471
|
-
path_name : str
|
|
472
|
-
Path name to resolve asynchronously.
|
|
417
|
+
Simulate async worker calculation with I/O delay.
|
|
473
418
|
|
|
474
419
|
Returns
|
|
475
420
|
-------
|
|
476
|
-
|
|
477
|
-
|
|
421
|
+
int
|
|
422
|
+
Calculated maximum workers count.
|
|
478
423
|
"""
|
|
479
424
|
await asyncio.sleep(0.01) # Simulate async I/O operation
|
|
480
|
-
return
|
|
481
|
-
|
|
482
|
-
# Test async
|
|
483
|
-
|
|
484
|
-
self.
|
|
485
|
-
|
|
486
|
-
|
|
425
|
+
return worker.calculate()
|
|
426
|
+
|
|
427
|
+
# Test async worker calculation
|
|
428
|
+
max_workers = await calculate_workers_async()
|
|
429
|
+
self.assertGreater(
|
|
430
|
+
max_workers,
|
|
431
|
+
0,
|
|
432
|
+
"Async worker calculation should return positive value"
|
|
487
433
|
)
|
|
488
434
|
|
|
489
435
|
async def testConcurrentOperations(self) -> None:
|
|
@@ -602,64 +548,108 @@ class TestAsynchronousExample(AsyncTestCase):
|
|
|
602
548
|
"""
|
|
603
549
|
Test async container dependency injection functionality.
|
|
604
550
|
|
|
605
|
-
Validates the container's ability to resolve services
|
|
606
|
-
|
|
607
|
-
|
|
551
|
+
Validates the application container's ability to resolve services and manage
|
|
552
|
+
dependencies in asynchronous contexts. This method demonstrates async dependency
|
|
553
|
+
injection patterns, service resolution capabilities, and validates that the
|
|
554
|
+
container can properly handle service lifecycle management in async environments.
|
|
555
|
+
The test ensures that services resolved through the container maintain their
|
|
556
|
+
functionality when used in asynchronous operations.
|
|
608
557
|
|
|
609
558
|
Parameters
|
|
610
559
|
----------
|
|
611
560
|
container : Application
|
|
612
|
-
Injected application container instance for testing async
|
|
613
|
-
|
|
561
|
+
Injected application container instance for testing async dependency
|
|
562
|
+
injection capabilities. The container manages service resolution,
|
|
563
|
+
dependency lifecycle, and provides access to registered services
|
|
564
|
+
throughout the async application context.
|
|
565
|
+
|
|
566
|
+
Returns
|
|
567
|
+
-------
|
|
568
|
+
None
|
|
569
|
+
This test method does not return any value. It performs assertions
|
|
570
|
+
to validate the container's async dependency injection functionality
|
|
571
|
+
and service resolution capabilities in asynchronous contexts.
|
|
614
572
|
|
|
615
573
|
Tests
|
|
616
574
|
-----
|
|
617
|
-
- Async service resolution from container
|
|
618
|
-
-
|
|
619
|
-
- Async
|
|
620
|
-
-
|
|
575
|
+
- Async service resolution from container using interface contracts
|
|
576
|
+
- Service instance validation after async resolution
|
|
577
|
+
- Async service method execution and functionality verification
|
|
578
|
+
- Dependency lifecycle management in async contexts
|
|
579
|
+
- Interface-to-implementation mapping in async scenarios
|
|
621
580
|
|
|
622
581
|
Raises
|
|
623
582
|
------
|
|
624
583
|
AssertionError
|
|
625
|
-
If async container operations fail
|
|
584
|
+
If async container operations fail, services cannot be resolved,
|
|
585
|
+
service methods return invalid results, or the container instance
|
|
586
|
+
fails to properly manage async dependencies.
|
|
587
|
+
|
|
588
|
+
Notes
|
|
589
|
+
-----
|
|
590
|
+
This test validates the core async dependency injection functionality
|
|
591
|
+
that is essential for the Orionis framework's async service architecture.
|
|
592
|
+
The container must be able to resolve services using their interface
|
|
593
|
+
contracts and provide properly configured instances that work correctly
|
|
594
|
+
in asynchronous execution contexts.
|
|
626
595
|
"""
|
|
627
|
-
async def resolve_service_async() ->
|
|
596
|
+
async def resolve_service_async() -> IWorkers:
|
|
628
597
|
"""
|
|
629
|
-
Simulate async service resolution.
|
|
598
|
+
Simulate async service resolution with I/O delay.
|
|
599
|
+
|
|
600
|
+
Demonstrates async service resolution from the container while
|
|
601
|
+
simulating real-world async I/O operations that might occur
|
|
602
|
+
during service instantiation or configuration.
|
|
630
603
|
|
|
631
604
|
Returns
|
|
632
605
|
-------
|
|
633
|
-
|
|
634
|
-
Resolved
|
|
606
|
+
IWorkers
|
|
607
|
+
Resolved worker service instance implementing the IWorkers interface.
|
|
635
608
|
"""
|
|
609
|
+
# Simulate async I/O operation that might occur during service resolution
|
|
636
610
|
await asyncio.sleep(0.01)
|
|
637
|
-
|
|
611
|
+
# Resolve the IWorkers service from the injected container
|
|
612
|
+
return container.make(IWorkers)
|
|
638
613
|
|
|
639
|
-
# Test async service resolution
|
|
640
|
-
|
|
614
|
+
# Test async service resolution from the container
|
|
615
|
+
# This validates that the container can resolve services in async contexts
|
|
616
|
+
worker_service = await resolve_service_async()
|
|
617
|
+
|
|
618
|
+
# Verify that the async service resolution was successful
|
|
619
|
+
# The container should return a valid instance implementing IWorkers
|
|
641
620
|
self.assertIsNotNone(
|
|
642
|
-
|
|
621
|
+
worker_service,
|
|
643
622
|
"Async service resolution should return valid instance"
|
|
644
623
|
)
|
|
645
624
|
|
|
646
|
-
async def use_service_async() ->
|
|
625
|
+
async def use_service_async() -> int:
|
|
647
626
|
"""
|
|
648
|
-
Simulate async service method execution.
|
|
627
|
+
Simulate async service method execution with I/O delay.
|
|
628
|
+
|
|
629
|
+
Demonstrates using a resolved service in an async context while
|
|
630
|
+
simulating real-world async operations that might be performed
|
|
631
|
+
by the service methods.
|
|
649
632
|
|
|
650
633
|
Returns
|
|
651
634
|
-------
|
|
652
|
-
|
|
653
|
-
Result from async service method call.
|
|
635
|
+
int
|
|
636
|
+
Result from async service method call representing worker count.
|
|
654
637
|
"""
|
|
638
|
+
# Simulate async I/O operation that might occur during service usage
|
|
655
639
|
await asyncio.sleep(0.01)
|
|
656
|
-
|
|
640
|
+
# Execute the calculate method on the resolved worker service
|
|
641
|
+
return worker_service.calculate()
|
|
657
642
|
|
|
658
|
-
# Test async service method execution
|
|
643
|
+
# Test async service method execution after resolution
|
|
644
|
+
# This validates that resolved services function properly in async contexts
|
|
659
645
|
result = await use_service_async()
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
646
|
+
|
|
647
|
+
# Verify that the async service method execution returns expected results
|
|
648
|
+
# The worker calculation should return a positive integer representing available workers
|
|
649
|
+
self.assertGreater(
|
|
650
|
+
result,
|
|
651
|
+
0,
|
|
652
|
+
"Async service method execution should return positive worker count"
|
|
663
653
|
)
|
|
664
654
|
|
|
665
655
|
async def testAsyncDataProcessing(self) -> None:
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from orionis.container.providers.service_provider import ServiceProvider
|
|
2
|
-
from orionis.services.paths.contracts.resolver import IResolver
|
|
3
|
-
from orionis.services.paths.resolver import Resolver
|
|
4
|
-
|
|
5
|
-
class PathResolverProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Registers the path resolution service in the application container.
|
|
8
|
-
|
|
9
|
-
This provider binds the `IResolver` interface to the `Resolver` implementation,
|
|
10
|
-
allowing the application to resolve file system paths through dependency injection.
|
|
11
|
-
|
|
12
|
-
Attributes
|
|
13
|
-
----------
|
|
14
|
-
app : Application
|
|
15
|
-
The application container instance inherited from ServiceProvider.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def register(self) -> None:
|
|
19
|
-
"""
|
|
20
|
-
Register the path resolver service in the application container.
|
|
21
|
-
|
|
22
|
-
Binds the `IResolver` interface to the `Resolver` implementation as a transient
|
|
23
|
-
service, with the alias "core.orionis.path_resolver".
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
None
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
self.app.transient(IResolver, Resolver, alias="core.orionis.path_resolver")
|
|
31
|
-
|
|
32
|
-
def boot(self) -> None:
|
|
33
|
-
"""
|
|
34
|
-
Perform post-registration initialization if needed.
|
|
35
|
-
|
|
36
|
-
This method is a placeholder for any actions required after service registration.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
None
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
class IResolver(ABC):
|
|
4
|
-
|
|
5
|
-
@abstractmethod
|
|
6
|
-
def relativePath(self, relative_path: str) -> 'IResolver':
|
|
7
|
-
"""
|
|
8
|
-
Resolves a relative path into an absolute one and validates its existence.
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
relative_path : str
|
|
13
|
-
The relative path to resolve.
|
|
14
|
-
|
|
15
|
-
Returns
|
|
16
|
-
-------
|
|
17
|
-
ResolverInterface
|
|
18
|
-
The instance itself for method chaining.
|
|
19
|
-
|
|
20
|
-
Raises
|
|
21
|
-
------
|
|
22
|
-
FileNotFoundError
|
|
23
|
-
If the resolved path does not exist.
|
|
24
|
-
ValueError
|
|
25
|
-
If the resolved path is neither a file nor a directory.
|
|
26
|
-
"""
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
@abstractmethod
|
|
30
|
-
def toString(self) -> str:
|
|
31
|
-
"""
|
|
32
|
-
Returns the resolved path as a string.
|
|
33
|
-
|
|
34
|
-
Returns
|
|
35
|
-
-------
|
|
36
|
-
str
|
|
37
|
-
The resolved path.
|
|
38
|
-
"""
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
@abstractmethod
|
|
42
|
-
def get(self):
|
|
43
|
-
"""
|
|
44
|
-
Returns the resolved path as a Path object.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
Path
|
|
49
|
-
The resolved path.
|
|
50
|
-
"""
|
|
51
|
-
pass
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
class OrionisPathValueException(Exception):
|
|
2
|
-
|
|
3
|
-
def __init__(self, msg: str):
|
|
4
|
-
"""
|
|
5
|
-
Parameters
|
|
6
|
-
----------
|
|
7
|
-
msg : str
|
|
8
|
-
Descriptive error message explaining the cause of the exception.
|
|
9
|
-
"""
|
|
10
|
-
super().__init__(msg)
|
|
11
|
-
|
|
12
|
-
def __str__(self) -> str:
|
|
13
|
-
"""
|
|
14
|
-
Returns
|
|
15
|
-
-------
|
|
16
|
-
str
|
|
17
|
-
Formatted string describing the exception.
|
|
18
|
-
"""
|
|
19
|
-
return str(self.args[0])
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
class OrionisFileNotFoundException(Exception):
|
|
2
|
-
|
|
3
|
-
def __init__(self, msg: str):
|
|
4
|
-
"""
|
|
5
|
-
Parameters
|
|
6
|
-
----------
|
|
7
|
-
msg : str
|
|
8
|
-
Descriptive error message explaining the cause of the exception.
|
|
9
|
-
"""
|
|
10
|
-
super().__init__(msg)
|
|
11
|
-
|
|
12
|
-
def __str__(self) -> str:
|
|
13
|
-
"""
|
|
14
|
-
Returns
|
|
15
|
-
-------
|
|
16
|
-
str
|
|
17
|
-
Formatted string describing the exception.
|
|
18
|
-
"""
|
|
19
|
-
return str(self.args[0])
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from orionis.services.paths.contracts.resolver import IResolver
|
|
4
|
-
from orionis.services.paths.exceptions import (
|
|
5
|
-
OrionisFileNotFoundException,
|
|
6
|
-
OrionisPathValueException
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
class Resolver(IResolver):
|
|
10
|
-
|
|
11
|
-
def __init__(self, root_path: str = None):
|
|
12
|
-
"""
|
|
13
|
-
Initializes the Resolver instance with the project's root directory.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
root_path : str, optional
|
|
18
|
-
The root directory of the project. If not provided, it defaults to the current working directory.
|
|
19
|
-
"""
|
|
20
|
-
self.base_path = Path(root_path).resolve() if root_path else Path(os.getcwd()).resolve()
|
|
21
|
-
self.resolved_path = None
|
|
22
|
-
|
|
23
|
-
def relativePath(self, relative_path: str) -> 'Resolver':
|
|
24
|
-
"""
|
|
25
|
-
Resolves a given relative path to an absolute path and validates its existence.
|
|
26
|
-
|
|
27
|
-
This method combines the project's root directory with the provided relative path,
|
|
28
|
-
resolves it to an absolute path, and ensures it exists as either a directory or a file.
|
|
29
|
-
|
|
30
|
-
Parameters
|
|
31
|
-
----------
|
|
32
|
-
relative_path : str
|
|
33
|
-
The relative path to a directory or file to be resolved.
|
|
34
|
-
|
|
35
|
-
Returns
|
|
36
|
-
-------
|
|
37
|
-
Resolver
|
|
38
|
-
The current instance of the Resolver class with the resolved path.
|
|
39
|
-
|
|
40
|
-
Raises
|
|
41
|
-
------
|
|
42
|
-
OrionisFileNotFoundException
|
|
43
|
-
If the resolved path does not exist.
|
|
44
|
-
OrionisPathValueException
|
|
45
|
-
If the resolved path is neither a valid directory nor a file.
|
|
46
|
-
"""
|
|
47
|
-
# Combine the base path with the relative path and resolve it
|
|
48
|
-
resolved_path = (self.base_path / relative_path).resolve()
|
|
49
|
-
|
|
50
|
-
# Validate that the path exists
|
|
51
|
-
if not resolved_path.exists():
|
|
52
|
-
raise OrionisFileNotFoundException(f"The requested path does not exist: {resolved_path}")
|
|
53
|
-
|
|
54
|
-
# Validate that the path is either a directory or a file
|
|
55
|
-
if not (resolved_path.is_dir() or resolved_path.is_file()):
|
|
56
|
-
raise OrionisPathValueException(f"The requested path is neither a valid directory nor a file: {resolved_path}")
|
|
57
|
-
|
|
58
|
-
# Store the resolved path in the instance variable
|
|
59
|
-
self.resolved_path = resolved_path
|
|
60
|
-
|
|
61
|
-
# Return the current instance
|
|
62
|
-
return self
|
|
63
|
-
|
|
64
|
-
def toString(self) -> str:
|
|
65
|
-
"""
|
|
66
|
-
Returns the string representation of the resolved path.
|
|
67
|
-
|
|
68
|
-
Returns
|
|
69
|
-
-------
|
|
70
|
-
str
|
|
71
|
-
The resolved path as a string.
|
|
72
|
-
"""
|
|
73
|
-
return str(self.resolved_path)
|
|
74
|
-
|
|
75
|
-
def get(self) -> Path:
|
|
76
|
-
"""
|
|
77
|
-
Returns the resolved path as a Path object.
|
|
78
|
-
|
|
79
|
-
Returns
|
|
80
|
-
-------
|
|
81
|
-
Path
|
|
82
|
-
The resolved path.
|
|
83
|
-
"""
|
|
84
|
-
return self.resolved_path
|
|
85
|
-
|
|
86
|
-
def __str__(self) -> str:
|
|
87
|
-
"""
|
|
88
|
-
Returns the string representation of the resolved path.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
str
|
|
93
|
-
The resolved path as a string.
|
|
94
|
-
"""
|
|
95
|
-
return str(self.resolved_path)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from orionis.container.facades.facade import Facade
|
|
2
|
-
|
|
3
|
-
class PathResolver(Facade):
|
|
4
|
-
|
|
5
|
-
@classmethod
|
|
6
|
-
def getFacadeAccessor(cls):
|
|
7
|
-
"""
|
|
8
|
-
Returns the binding key for the path resolver service in the container.
|
|
9
|
-
|
|
10
|
-
Returns
|
|
11
|
-
-------
|
|
12
|
-
str
|
|
13
|
-
The unique string identifier for the path resolver service, used by the service container.
|
|
14
|
-
"""
|
|
15
|
-
return "core.orionis.path_resolver"
|
tests/services/path/__init__.py
DELETED
|
File without changes
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import tempfile
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from orionis.services.paths.exceptions import OrionisFileNotFoundException
|
|
5
|
-
from orionis.services.paths.resolver import Resolver
|
|
6
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
7
|
-
|
|
8
|
-
class TestServicesResolver(AsyncTestCase):
|
|
9
|
-
|
|
10
|
-
async def testFileNotFound(self):
|
|
11
|
-
"""
|
|
12
|
-
Test that resolving a non-existent file path raises OrionisFileNotFoundException.
|
|
13
|
-
|
|
14
|
-
Returns
|
|
15
|
-
-------
|
|
16
|
-
None
|
|
17
|
-
|
|
18
|
-
Raises
|
|
19
|
-
------
|
|
20
|
-
OrionisFileNotFoundException
|
|
21
|
-
If the file does not exist.
|
|
22
|
-
"""
|
|
23
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
24
|
-
resolver = Resolver(tmpdir)
|
|
25
|
-
non_existent = "does_not_exist.txt"
|
|
26
|
-
with self.assertRaises(OrionisFileNotFoundException):
|
|
27
|
-
resolver.relativePath(non_existent)
|
|
28
|
-
|
|
29
|
-
async def testValidFilePath(self):
|
|
30
|
-
"""
|
|
31
|
-
Test that resolving a valid file path returns the correct absolute path.
|
|
32
|
-
|
|
33
|
-
Returns
|
|
34
|
-
-------
|
|
35
|
-
None
|
|
36
|
-
|
|
37
|
-
Asserts
|
|
38
|
-
-------
|
|
39
|
-
The resolved path ends with the file name and is absolute.
|
|
40
|
-
"""
|
|
41
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
42
|
-
# Create a temporary file inside the temp directory
|
|
43
|
-
file_path = Path(tmpdir) / "testfile.txt"
|
|
44
|
-
file_path.write_text("sample content")
|
|
45
|
-
resolver = Resolver(tmpdir)
|
|
46
|
-
resolved = resolver.relativePath("testfile.txt").toString()
|
|
47
|
-
# The resolved path should end with the file name
|
|
48
|
-
self.assertTrue(resolved.endswith("testfile.txt"))
|
|
49
|
-
# The resolved path should be absolute
|
|
50
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
51
|
-
|
|
52
|
-
async def testValidDirectoryPath(self):
|
|
53
|
-
"""
|
|
54
|
-
Test that resolving a valid directory path returns the correct absolute path.
|
|
55
|
-
|
|
56
|
-
Returns
|
|
57
|
-
-------
|
|
58
|
-
None
|
|
59
|
-
|
|
60
|
-
Asserts
|
|
61
|
-
-------
|
|
62
|
-
The resolved path ends with the directory name and is absolute.
|
|
63
|
-
"""
|
|
64
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
65
|
-
# Create a subdirectory inside the temp directory
|
|
66
|
-
subdir = Path(tmpdir) / "subdir"
|
|
67
|
-
subdir.mkdir()
|
|
68
|
-
resolver = Resolver(tmpdir)
|
|
69
|
-
resolved = resolver.relativePath("subdir").toString()
|
|
70
|
-
self.assertTrue(resolved.endswith("subdir"))
|
|
71
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
72
|
-
|
|
73
|
-
async def testOtherBasePath(self):
|
|
74
|
-
"""
|
|
75
|
-
Test that providing a different base path to Resolver works as expected.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
None
|
|
80
|
-
|
|
81
|
-
Asserts
|
|
82
|
-
-------
|
|
83
|
-
The resolved path ends with the file name and is absolute.
|
|
84
|
-
"""
|
|
85
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
86
|
-
# Create a file in a subdirectory
|
|
87
|
-
subdir = Path(tmpdir) / "base"
|
|
88
|
-
subdir.mkdir()
|
|
89
|
-
file_path = subdir / "file.txt"
|
|
90
|
-
file_path.write_text("data")
|
|
91
|
-
resolver = Resolver(str(subdir))
|
|
92
|
-
resolved = resolver.relativePath("file.txt").toString()
|
|
93
|
-
self.assertTrue(resolved.endswith("file.txt"))
|
|
94
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
95
|
-
|
|
96
|
-
async def testEqualOutputString(self):
|
|
97
|
-
"""
|
|
98
|
-
Test that the string representation of the resolved path matches the output of toString().
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
None
|
|
103
|
-
|
|
104
|
-
Asserts
|
|
105
|
-
-------
|
|
106
|
-
The string representation of the resolved path matches the output of toString().
|
|
107
|
-
"""
|
|
108
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
109
|
-
file_path = Path(tmpdir) / "file.txt"
|
|
110
|
-
file_path.write_text("abc")
|
|
111
|
-
resolver = Resolver(tmpdir).relativePath("file.txt")
|
|
112
|
-
self.assertEqual(resolver.toString(), str(resolver))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|