orionis 0.431.0__py3-none-any.whl → 0.434.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/app.py +17 -0
- orionis/console/commands/version.py +2 -2
- orionis/console/core/reactor.py +1 -1
- orionis/foundation/config/roots/paths.py +2 -2
- orionis/metadata/framework.py +38 -65
- orionis/metadata/package.py +280 -54
- orionis/support/entities/base.py +18 -37
- orionis/support/facades/console.py +3 -9
- orionis/support/facades/dumper.py +3 -9
- orionis/support/facades/logger.py +3 -9
- orionis/support/facades/path_resolver.py +3 -10
- orionis/support/facades/progress_bar.py +3 -10
- orionis/support/facades/testing.py +4 -10
- orionis/support/facades/workers.py +4 -9
- orionis/support/formatter/exceptions/contracts/parser.py +10 -7
- orionis/support/formatter/exceptions/parser.py +28 -26
- orionis/support/formatter/serializer.py +12 -5
- orionis/support/patterns/singleton/meta.py +17 -21
- orionis/support/standard/contracts/std.py +25 -24
- orionis/support/standard/exceptions/value.py +2 -2
- orionis/support/standard/std.py +26 -24
- orionis/support/wrapper/dot_dict.py +16 -51
- orionis/test/cases/asynchronous.py +17 -81
- orionis/test/cases/synchronous.py +17 -73
- orionis/test/contracts/dumper.py +17 -21
- orionis/test/contracts/kernel.py +5 -12
- orionis/test/contracts/logs.py +16 -21
- orionis/test/contracts/printer.py +70 -8
- orionis/test/contracts/render.py +7 -13
- orionis/test/contracts/test_result.py +58 -27
- orionis/test/contracts/unit_test.py +18 -18
- orionis/test/core/unit_test.py +162 -519
- orionis/test/entities/result.py +49 -21
- orionis/test/enums/status.py +11 -17
- orionis/test/exceptions/config.py +4 -8
- orionis/test/exceptions/failure.py +2 -18
- orionis/test/exceptions/persistence.py +4 -8
- orionis/test/exceptions/runtime.py +4 -8
- orionis/test/exceptions/value.py +5 -13
- orionis/test/kernel.py +14 -42
- orionis/test/output/dumper.py +21 -43
- orionis/test/output/printer.py +6 -146
- orionis/test/records/logs.py +57 -121
- orionis/test/validators/base_path.py +8 -6
- orionis/test/validators/execution_mode.py +2 -3
- orionis/test/validators/fail_fast.py +4 -8
- orionis/test/validators/folder_path.py +5 -7
- orionis/test/validators/module_name.py +3 -3
- orionis/test/validators/name_pattern.py +4 -9
- orionis/test/validators/pattern.py +4 -9
- orionis/test/validators/persistent.py +4 -14
- orionis/test/validators/persistent_driver.py +7 -12
- orionis/test/validators/print_result.py +4 -9
- orionis/test/validators/tags.py +6 -7
- orionis/test/validators/throw_exception.py +7 -14
- orionis/test/validators/verbosity.py +15 -5
- orionis/test/validators/web_report.py +6 -10
- orionis/test/validators/workers.py +9 -4
- orionis/test/view/render.py +9 -26
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/METADATA +1 -1
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/RECORD +82 -81
- tests/metadata/test_metadata_framework.py +64 -90
- tests/metadata/test_metadata_package.py +31 -31
- tests/support/entities/mock_dataclass.py +16 -10
- tests/support/entities/test_base.py +6 -14
- tests/support/patterns/singleton/test_patterns_singleton.py +7 -8
- tests/support/standard/test_services_std.py +113 -37
- tests/support/wrapper/test_services_wrapper_docdict.py +25 -40
- tests/testing/cases/test_testing_asynchronous.py +14 -14
- tests/testing/cases/test_testing_synchronous.py +12 -14
- tests/testing/entities/test_testing_result.py +12 -51
- tests/testing/enums/test_testing_status.py +8 -13
- tests/testing/output/test_testing_dumper.py +3 -6
- tests/testing/output/test_testing_printer.py +5 -5
- tests/testing/records/test_testing_records.py +16 -26
- tests/testing/test_testing_unit.py +8 -94
- tests/testing/validators/test_testing_validators.py +55 -112
- tests/testing/view/test_render.py +4 -5
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/WHEEL +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/top_level.txt +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/zip-safe +0 -0
orionis/test/output/printer.py
CHANGED
|
@@ -23,10 +23,6 @@ class TestPrinter(ITestPrinter):
|
|
|
23
23
|
"""
|
|
24
24
|
Initialize a TestPrinter instance for formatted test output.
|
|
25
25
|
|
|
26
|
-
This constructor sets up the Rich Console for rendering output, configures
|
|
27
|
-
the panel title and width for display, and defines keywords used to detect
|
|
28
|
-
debugging calls in test code.
|
|
29
|
-
|
|
30
26
|
Parameters
|
|
31
27
|
----------
|
|
32
28
|
print_result : bool, optional
|
|
@@ -39,16 +35,6 @@ class TestPrinter(ITestPrinter):
|
|
|
39
35
|
Returns
|
|
40
36
|
-------
|
|
41
37
|
None
|
|
42
|
-
This method does not return a value. It initializes instance attributes for output formatting.
|
|
43
|
-
|
|
44
|
-
Notes
|
|
45
|
-
-----
|
|
46
|
-
- Initializes the following attributes:
|
|
47
|
-
- __rich_console: Rich Console instance for formatted terminal output.
|
|
48
|
-
- __panel_title: Title string for the output panel.
|
|
49
|
-
- __panel_width: Width of the output panel, calculated as a percentage of the console width.
|
|
50
|
-
- __debbug_keywords: List of keywords for identifying debug calls in test code.
|
|
51
|
-
- __print_result: Flag indicating whether to print results.
|
|
52
38
|
"""
|
|
53
39
|
# Create a Rich Console instance for output rendering
|
|
54
40
|
self.__rich_console = Console()
|
|
@@ -70,11 +56,7 @@ class TestPrinter(ITestPrinter):
|
|
|
70
56
|
value: Any
|
|
71
57
|
) -> None:
|
|
72
58
|
"""
|
|
73
|
-
Print a value to the console using the Rich library
|
|
74
|
-
|
|
75
|
-
This method provides a unified way to output various types of values to the console,
|
|
76
|
-
leveraging Rich's formatting capabilities. It handles strings, objects, and lists,
|
|
77
|
-
ensuring each is displayed appropriately.
|
|
59
|
+
Print a value to the console using the Rich library.
|
|
78
60
|
|
|
79
61
|
Parameters
|
|
80
62
|
----------
|
|
@@ -84,15 +66,7 @@ class TestPrinter(ITestPrinter):
|
|
|
84
66
|
Returns
|
|
85
67
|
-------
|
|
86
68
|
None
|
|
87
|
-
This method does not return any value. It outputs the provided value(s) to the console.
|
|
88
|
-
|
|
89
|
-
Notes
|
|
90
|
-
-----
|
|
91
|
-
- If the value is a string, it is printed directly.
|
|
92
|
-
- If the value is a list, each item in the list is printed on a new line.
|
|
93
|
-
- For any other object, its string representation is printed.
|
|
94
69
|
"""
|
|
95
|
-
|
|
96
70
|
# If not printing results, return early
|
|
97
71
|
if self.__print_result is False:
|
|
98
72
|
return
|
|
@@ -120,11 +94,6 @@ class TestPrinter(ITestPrinter):
|
|
|
120
94
|
"""
|
|
121
95
|
Display a formatted start message for the test execution session.
|
|
122
96
|
|
|
123
|
-
This method prints a styled panel to the console at the beginning of a test run,
|
|
124
|
-
providing key information about the test session such as the total number of tests,
|
|
125
|
-
the execution mode (parallel or sequential), and the start time. The output is
|
|
126
|
-
rendered using the Rich library for enhanced readability.
|
|
127
|
-
|
|
128
97
|
Parameters
|
|
129
98
|
----------
|
|
130
99
|
length_tests : int
|
|
@@ -137,14 +106,7 @@ class TestPrinter(ITestPrinter):
|
|
|
137
106
|
Returns
|
|
138
107
|
-------
|
|
139
108
|
None
|
|
140
|
-
This method does not return any value. It only prints formatted output to the console.
|
|
141
|
-
|
|
142
|
-
Notes
|
|
143
|
-
-----
|
|
144
|
-
- The message is only printed if the `print_result` flag is set to True.
|
|
145
|
-
- The panel includes the total number of tests, execution mode, and the current timestamp.
|
|
146
109
|
"""
|
|
147
|
-
|
|
148
110
|
# If not printing results, return early
|
|
149
111
|
if self.__print_result is False:
|
|
150
112
|
return
|
|
@@ -185,11 +147,6 @@ class TestPrinter(ITestPrinter):
|
|
|
185
147
|
"""
|
|
186
148
|
Display a final summary message for the test suite execution in a styled panel.
|
|
187
149
|
|
|
188
|
-
This method prints a completion message at the end of the test run, summarizing the overall
|
|
189
|
-
status and total execution time. The message includes a status icon (✅ for success, ❌ for failure)
|
|
190
|
-
based on whether any tests failed or errored. The output is formatted using the Rich library
|
|
191
|
-
for enhanced readability.
|
|
192
|
-
|
|
193
150
|
Parameters
|
|
194
151
|
----------
|
|
195
152
|
summary : dict
|
|
@@ -201,15 +158,7 @@ class TestPrinter(ITestPrinter):
|
|
|
201
158
|
Returns
|
|
202
159
|
-------
|
|
203
160
|
None
|
|
204
|
-
This method does not return any value. It outputs a formatted completion message to the console.
|
|
205
|
-
|
|
206
|
-
Notes
|
|
207
|
-
-----
|
|
208
|
-
- If `self.__print_result` is False, the method returns without displaying anything.
|
|
209
|
-
- The status icon reflects the presence of failures or errors in the test suite.
|
|
210
|
-
- The message is displayed within a styled Rich panel for clarity.
|
|
211
161
|
"""
|
|
212
|
-
|
|
213
162
|
# If not printing results, return early
|
|
214
163
|
if self.__print_result is False:
|
|
215
164
|
return
|
|
@@ -244,12 +193,6 @@ class TestPrinter(ITestPrinter):
|
|
|
244
193
|
"""
|
|
245
194
|
Execute a test suite panel with optional live console output and debugging detection.
|
|
246
195
|
|
|
247
|
-
This method manages the display of a running message panel using the Rich library,
|
|
248
|
-
adapting its behavior based on whether debugging or dump calls are detected in the test suite
|
|
249
|
-
and whether result printing is enabled. If debugging or dump calls are present in the test code,
|
|
250
|
-
a static panel is shown before executing the test suite. Otherwise, a live panel is displayed
|
|
251
|
-
during execution for a more dynamic user experience.
|
|
252
|
-
|
|
253
196
|
Parameters
|
|
254
197
|
----------
|
|
255
198
|
flatten_test_suite : list
|
|
@@ -260,16 +203,8 @@ class TestPrinter(ITestPrinter):
|
|
|
260
203
|
Returns
|
|
261
204
|
-------
|
|
262
205
|
Any
|
|
263
|
-
Returns the result produced by the provided callable after execution
|
|
264
|
-
contains the outcome of the test suite run (such as a summary or result object).
|
|
265
|
-
|
|
266
|
-
Notes
|
|
267
|
-
-----
|
|
268
|
-
- If debugging or dump calls are detected in the test code, a static panel is displayed.
|
|
269
|
-
- If no debugging or dump calls are found and result printing is enabled, a live panel is shown.
|
|
270
|
-
- If result printing is disabled, the test suite is executed without any panel display.
|
|
206
|
+
Returns the result produced by the provided callable after execution.
|
|
271
207
|
"""
|
|
272
|
-
|
|
273
208
|
# Determine if the test suite contains active debugging or dump calls
|
|
274
209
|
use_debugger = self.__withDebugger(
|
|
275
210
|
flatten_test_suite=flatten_test_suite
|
|
@@ -311,10 +246,6 @@ class TestPrinter(ITestPrinter):
|
|
|
311
246
|
"""
|
|
312
247
|
Display a styled message inviting the user to view the test results report.
|
|
313
248
|
|
|
314
|
-
This method prints an elegant invitation to the console, indicating that the test results
|
|
315
|
-
have been saved and providing a clickable or visually distinct path to the report. The output
|
|
316
|
-
uses Rich's Text styling to highlight the message and underline the report path for emphasis.
|
|
317
|
-
|
|
318
249
|
Parameters
|
|
319
250
|
----------
|
|
320
251
|
path : str
|
|
@@ -323,14 +254,7 @@ class TestPrinter(ITestPrinter):
|
|
|
323
254
|
Returns
|
|
324
255
|
-------
|
|
325
256
|
None
|
|
326
|
-
This method does not return any value. It outputs a formatted message to the console.
|
|
327
|
-
|
|
328
|
-
Notes
|
|
329
|
-
-----
|
|
330
|
-
- The invitation message is styled with green text for success and an underlined blue path for visibility.
|
|
331
|
-
- Intended to be called after test execution to direct users to the generated report.
|
|
332
257
|
"""
|
|
333
|
-
|
|
334
258
|
# If not printing results, do not display the link
|
|
335
259
|
if self.__print_result is False:
|
|
336
260
|
return
|
|
@@ -354,11 +278,6 @@ class TestPrinter(ITestPrinter):
|
|
|
354
278
|
"""
|
|
355
279
|
Display a summary table of test results using the Rich library.
|
|
356
280
|
|
|
357
|
-
This method prints a formatted table summarizing the results of a test suite execution.
|
|
358
|
-
The table includes the total number of tests, counts of passed, failed, errored, and skipped tests,
|
|
359
|
-
the total execution duration, and the overall success rate. The output is styled for readability
|
|
360
|
-
and is only displayed if result printing is enabled.
|
|
361
|
-
|
|
362
281
|
Parameters
|
|
363
282
|
----------
|
|
364
283
|
summary : dict
|
|
@@ -374,15 +293,7 @@ class TestPrinter(ITestPrinter):
|
|
|
374
293
|
Returns
|
|
375
294
|
-------
|
|
376
295
|
None
|
|
377
|
-
This method does not return any value. It outputs a formatted summary table to the console
|
|
378
|
-
if result printing is enabled.
|
|
379
|
-
|
|
380
|
-
Notes
|
|
381
|
-
-----
|
|
382
|
-
- The table is only displayed if the `print_result` flag is set to True.
|
|
383
|
-
- The table uses Rich's styling features for enhanced readability.
|
|
384
296
|
"""
|
|
385
|
-
|
|
386
297
|
# If result printing is disabled, do not display the summary table
|
|
387
298
|
if self.__print_result is False:
|
|
388
299
|
return
|
|
@@ -429,12 +340,6 @@ class TestPrinter(ITestPrinter):
|
|
|
429
340
|
Display a detailed summary of test execution results, including a summary table and
|
|
430
341
|
grouped panels for failed or errored tests.
|
|
431
342
|
|
|
432
|
-
This method prints a summary table of the test results and, if there are any failed or
|
|
433
|
-
errored tests, displays them grouped by their test class. For each failed or errored test,
|
|
434
|
-
a syntax-highlighted traceback panel is shown, along with metadata such as the test method
|
|
435
|
-
name and execution time. Different icons and border colors are used to distinguish between
|
|
436
|
-
failed and errored tests.
|
|
437
|
-
|
|
438
343
|
Parameters
|
|
439
344
|
----------
|
|
440
345
|
summary : dict
|
|
@@ -445,20 +350,7 @@ class TestPrinter(ITestPrinter):
|
|
|
445
350
|
Returns
|
|
446
351
|
-------
|
|
447
352
|
None
|
|
448
|
-
This method does not return any value. It outputs the formatted summary table and
|
|
449
|
-
detailed panels for failed or errored tests to the console.
|
|
450
|
-
|
|
451
|
-
Notes
|
|
452
|
-
-----
|
|
453
|
-
- The summary table provides an overview of the test results.
|
|
454
|
-
- Failed and errored tests are grouped and displayed by their test class.
|
|
455
|
-
- Each failed or errored test is shown in a panel with a syntax-highlighted traceback,
|
|
456
|
-
test method name, and execution time.
|
|
457
|
-
- Icons and border colors visually distinguish between failed (❌, yellow) and errored
|
|
458
|
-
(💥, red) tests.
|
|
459
|
-
- No output is produced if result printing is disabled.
|
|
460
353
|
"""
|
|
461
|
-
|
|
462
354
|
# If result printing is disabled, do not display results
|
|
463
355
|
if not self.__print_result:
|
|
464
356
|
return
|
|
@@ -532,14 +424,9 @@ class TestPrinter(ITestPrinter):
|
|
|
532
424
|
"""
|
|
533
425
|
Display the result of a single unit test in a formatted manner using the Rich library.
|
|
534
426
|
|
|
535
|
-
This method prints the outcome of an individual unit test to the console, showing a status icon
|
|
536
|
-
(✅ for passed, ❌ for failed) along with the test name. If the test failed, the first line of the
|
|
537
|
-
error message is also displayed for quick reference. The output is styled for clarity and does not
|
|
538
|
-
use syntax highlighting.
|
|
539
|
-
|
|
540
427
|
Parameters
|
|
541
428
|
----------
|
|
542
|
-
test_result :
|
|
429
|
+
test_result : TestResult
|
|
543
430
|
An object representing the result of a unit test. It must have the following attributes:
|
|
544
431
|
- status: An enum or object with a 'name' attribute indicating the test status (e.g., "PASSED", "FAILED").
|
|
545
432
|
- name: The name of the test.
|
|
@@ -548,15 +435,7 @@ class TestPrinter(ITestPrinter):
|
|
|
548
435
|
Returns
|
|
549
436
|
-------
|
|
550
437
|
None
|
|
551
|
-
This method does not return any value. It outputs the formatted test result to the console.
|
|
552
|
-
|
|
553
|
-
Notes
|
|
554
|
-
-----
|
|
555
|
-
- If the test passed, only the status and test name are displayed.
|
|
556
|
-
- If the test failed, the status, test name, and the first line of the error message are shown.
|
|
557
|
-
- Output is printed using the Rich console without syntax highlighting.
|
|
558
438
|
"""
|
|
559
|
-
|
|
560
439
|
# If result printing is disabled, do not display results
|
|
561
440
|
if not self.__print_result:
|
|
562
441
|
return
|
|
@@ -589,11 +468,6 @@ class TestPrinter(ITestPrinter):
|
|
|
589
468
|
"""
|
|
590
469
|
Determine if any test case in the provided flattened test suite contains active debugging or dumping calls.
|
|
591
470
|
|
|
592
|
-
This method inspects the source code of each test case instance in the given list to check for the presence
|
|
593
|
-
of specific debugging or dumping method calls (such as 'self.dd' or 'self.dump'). Only lines that are not
|
|
594
|
-
commented out are considered. If any such call is found in the source code, the method immediately returns True,
|
|
595
|
-
indicating that a debugger or dump method is actively used in the test suite.
|
|
596
|
-
|
|
597
471
|
Parameters
|
|
598
472
|
----------
|
|
599
473
|
flatten_test_suite : list
|
|
@@ -602,16 +476,9 @@ class TestPrinter(ITestPrinter):
|
|
|
602
476
|
Returns
|
|
603
477
|
-------
|
|
604
478
|
bool
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
during inspection.
|
|
608
|
-
|
|
609
|
-
Notes
|
|
610
|
-
-----
|
|
611
|
-
- Lines that are commented out (i.e., start with '#') are ignored during inspection.
|
|
612
|
-
- If an exception occurs while retrieving or processing the source code, the method returns False.
|
|
479
|
+
True if any test case contains an active (non-commented) call to a debugging or dumping method.
|
|
480
|
+
False if no such calls are found or if an exception occurs during inspection.
|
|
613
481
|
"""
|
|
614
|
-
|
|
615
482
|
try:
|
|
616
483
|
|
|
617
484
|
# Iterate through each test case in the flattened test suite
|
|
@@ -650,12 +517,6 @@ class TestPrinter(ITestPrinter):
|
|
|
650
517
|
"""
|
|
651
518
|
Extract and return the most relevant portion of a traceback string that pertains to a specific test file.
|
|
652
519
|
|
|
653
|
-
This method processes a full Python traceback and attempts to isolate the lines that are directly related
|
|
654
|
-
to the provided test file. It does so by searching for the test file's name within the traceback and collecting
|
|
655
|
-
all subsequent lines that are relevant, such as those containing 'File' or non-empty lines. If the test file's
|
|
656
|
-
name cannot be determined or no relevant lines are found, the original traceback is returned. If the traceback
|
|
657
|
-
is empty, a default message is returned.
|
|
658
|
-
|
|
659
520
|
Parameters
|
|
660
521
|
----------
|
|
661
522
|
test_path : str
|
|
@@ -666,11 +527,10 @@ class TestPrinter(ITestPrinter):
|
|
|
666
527
|
Returns
|
|
667
528
|
-------
|
|
668
529
|
str
|
|
669
|
-
|
|
530
|
+
String containing only the relevant traceback lines associated with the test file.
|
|
670
531
|
If no relevant lines are found or the file name cannot be determined, the full traceback is returned.
|
|
671
532
|
If the traceback is empty, returns "No traceback available for this test."
|
|
672
533
|
"""
|
|
673
|
-
|
|
674
534
|
# Return a default message if the traceback is empty
|
|
675
535
|
if not traceback_test:
|
|
676
536
|
return "No traceback available for this test."
|
orionis/test/records/logs.py
CHANGED
|
@@ -12,24 +12,18 @@ class TestLogs(ITestLogs):
|
|
|
12
12
|
storage_path: str
|
|
13
13
|
) -> None:
|
|
14
14
|
"""
|
|
15
|
-
Initialize
|
|
16
|
-
|
|
17
|
-
This constructor sets up the database file and table names, ensures the storage directory exists,
|
|
18
|
-
and prepares the absolute path for the SQLite database file. The database connection is initialized
|
|
19
|
-
as None and will be established when needed.
|
|
15
|
+
Initialize the TestLogs instance, setting up the SQLite database path and connection.
|
|
20
16
|
|
|
21
17
|
Parameters
|
|
22
18
|
----------
|
|
23
19
|
storage_path : str
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
Directory path where the SQLite database file ('tests.sqlite') will be stored. The directory
|
|
21
|
+
will be created if it does not exist.
|
|
26
22
|
|
|
27
23
|
Returns
|
|
28
24
|
-------
|
|
29
25
|
None
|
|
30
|
-
This method does not return a value.
|
|
31
26
|
"""
|
|
32
|
-
|
|
33
27
|
# Set the database file and table names
|
|
34
28
|
self.__db_name = 'tests.sqlite'
|
|
35
29
|
self.__table_name = 'reports'
|
|
@@ -51,11 +45,7 @@ class TestLogs(ITestLogs):
|
|
|
51
45
|
self
|
|
52
46
|
) -> None:
|
|
53
47
|
"""
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
This method checks if a database connection is already established. If not, it attempts to create a new
|
|
57
|
-
SQLite connection using the absolute path specified during initialization. If the connection attempt fails,
|
|
58
|
-
it raises an OrionisTestPersistenceError with the error details.
|
|
48
|
+
Establish a connection to the SQLite database if not already connected.
|
|
59
49
|
|
|
60
50
|
Raises
|
|
61
51
|
------
|
|
@@ -65,10 +55,7 @@ class TestLogs(ITestLogs):
|
|
|
65
55
|
Returns
|
|
66
56
|
-------
|
|
67
57
|
None
|
|
68
|
-
This method does not return a value. It sets the self._conn attribute to an active SQLite connection
|
|
69
|
-
if successful, or raises an exception if the connection fails.
|
|
70
58
|
"""
|
|
71
|
-
|
|
72
59
|
# Only connect if there is no existing connection
|
|
73
60
|
if self._conn is None:
|
|
74
61
|
|
|
@@ -96,26 +83,18 @@ class TestLogs(ITestLogs):
|
|
|
96
83
|
self
|
|
97
84
|
) -> bool:
|
|
98
85
|
"""
|
|
99
|
-
|
|
86
|
+
Ensure the reports table exists in the SQLite database.
|
|
100
87
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
an OrionisTestPersistenceError is raised.
|
|
88
|
+
Returns
|
|
89
|
+
-------
|
|
90
|
+
bool
|
|
91
|
+
True if the table was created or already exists.
|
|
106
92
|
|
|
107
93
|
Raises
|
|
108
94
|
------
|
|
109
95
|
OrionisTestPersistenceError
|
|
110
|
-
If
|
|
111
|
-
|
|
112
|
-
Returns
|
|
113
|
-
-------
|
|
114
|
-
bool
|
|
115
|
-
Returns True if the table was created successfully or already exists.
|
|
116
|
-
Returns False only if an unexpected error occurs (which will typically raise an exception).
|
|
96
|
+
If table creation fails due to a database error.
|
|
117
97
|
"""
|
|
118
|
-
|
|
119
98
|
# Establish a connection to the database
|
|
120
99
|
self.__connect()
|
|
121
100
|
|
|
@@ -167,24 +146,18 @@ class TestLogs(ITestLogs):
|
|
|
167
146
|
report: Dict
|
|
168
147
|
) -> bool:
|
|
169
148
|
"""
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
This method validates the provided report dictionary to ensure all required fields are present,
|
|
173
|
-
serializes the report as JSON, and inserts it into the database table. If any required field is missing,
|
|
174
|
-
or if a database error occurs during insertion, an appropriate exception is raised.
|
|
149
|
+
Insert a test report into the reports table.
|
|
175
150
|
|
|
176
151
|
Parameters
|
|
177
152
|
----------
|
|
178
|
-
report :
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
- success_rate
|
|
187
|
-
- timestamp
|
|
153
|
+
report : dict
|
|
154
|
+
Dictionary containing the report data. Must include keys:
|
|
155
|
+
'total_tests', 'passed', 'failed', 'errors', 'skipped', 'total_time', 'success_rate', 'timestamp'.
|
|
156
|
+
|
|
157
|
+
Returns
|
|
158
|
+
-------
|
|
159
|
+
bool
|
|
160
|
+
True if the report was successfully inserted.
|
|
188
161
|
|
|
189
162
|
Raises
|
|
190
163
|
------
|
|
@@ -192,14 +165,7 @@ class TestLogs(ITestLogs):
|
|
|
192
165
|
If there is an error inserting the report into the database.
|
|
193
166
|
OrionisTestValueError
|
|
194
167
|
If required fields are missing from the report.
|
|
195
|
-
|
|
196
|
-
Returns
|
|
197
|
-
-------
|
|
198
|
-
bool
|
|
199
|
-
Returns True if the report was successfully inserted into the database.
|
|
200
|
-
Returns False only if an unexpected error occurs (which will typically raise an exception).
|
|
201
168
|
"""
|
|
202
|
-
|
|
203
169
|
# List of required fields for the report
|
|
204
170
|
fields = [
|
|
205
171
|
"json", "total_tests", "passed", "failed", "errors",
|
|
@@ -267,26 +233,19 @@ class TestLogs(ITestLogs):
|
|
|
267
233
|
last: Optional[int] = None
|
|
268
234
|
) -> List[Tuple]:
|
|
269
235
|
"""
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
This method allows fetching either the earliest or latest test reports from the database,
|
|
273
|
-
depending on the parameters provided. If `first` is specified, it retrieves the earliest
|
|
274
|
-
reports in ascending order by ID. If `last` is specified, it retrieves the latest reports
|
|
275
|
-
in descending order by ID. Only one of `first` or `last` can be provided at a time.
|
|
236
|
+
Retrieve a specified number of report records from the database.
|
|
276
237
|
|
|
277
238
|
Parameters
|
|
278
239
|
----------
|
|
279
|
-
first :
|
|
280
|
-
|
|
281
|
-
last :
|
|
282
|
-
|
|
240
|
+
first : int or None, optional
|
|
241
|
+
Number of earliest reports to retrieve, ordered by ascending ID.
|
|
242
|
+
last : int or None, optional
|
|
243
|
+
Number of latest reports to retrieve, ordered by descending ID.
|
|
283
244
|
|
|
284
245
|
Returns
|
|
285
246
|
-------
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
Each tuple contains all columns from the reports table, including the serialized JSON report
|
|
289
|
-
and associated statistics.
|
|
247
|
+
list of tuple
|
|
248
|
+
List of tuples representing report records.
|
|
290
249
|
|
|
291
250
|
Raises
|
|
292
251
|
------
|
|
@@ -295,7 +254,6 @@ class TestLogs(ITestLogs):
|
|
|
295
254
|
OrionisTestPersistenceError
|
|
296
255
|
If there is an error retrieving reports from the database.
|
|
297
256
|
"""
|
|
298
|
-
|
|
299
257
|
# Ensure that only one of 'first' or 'last' is specified
|
|
300
258
|
if first is not None and last is not None:
|
|
301
259
|
raise OrionisTestValueError(
|
|
@@ -350,24 +308,18 @@ class TestLogs(ITestLogs):
|
|
|
350
308
|
self
|
|
351
309
|
) -> bool:
|
|
352
310
|
"""
|
|
353
|
-
|
|
311
|
+
Drop the reports table from the SQLite database.
|
|
354
312
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
313
|
+
Returns
|
|
314
|
+
-------
|
|
315
|
+
bool
|
|
316
|
+
True if the table was successfully dropped or did not exist.
|
|
358
317
|
|
|
359
318
|
Raises
|
|
360
319
|
------
|
|
361
320
|
OrionisTestPersistenceError
|
|
362
321
|
If an SQLite error occurs while attempting to drop the table.
|
|
363
|
-
|
|
364
|
-
Returns
|
|
365
|
-
-------
|
|
366
|
-
bool
|
|
367
|
-
Returns True if the table was successfully dropped or did not exist.
|
|
368
|
-
Returns False only if an unexpected error occurs (which will typically raise an exception).
|
|
369
322
|
"""
|
|
370
|
-
|
|
371
323
|
# Establish a connection to the database
|
|
372
324
|
self.__connect()
|
|
373
325
|
|
|
@@ -399,18 +351,12 @@ class TestLogs(ITestLogs):
|
|
|
399
351
|
self
|
|
400
352
|
) -> None:
|
|
401
353
|
"""
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
This method checks whether a database connection is currently open. If so, it closes the connection
|
|
405
|
-
to release any associated resources and sets the connection attribute to None to indicate that
|
|
406
|
-
there is no active connection.
|
|
354
|
+
Close the active SQLite database connection if it exists.
|
|
407
355
|
|
|
408
356
|
Returns
|
|
409
357
|
-------
|
|
410
358
|
None
|
|
411
|
-
This method does not return a value. It ensures that the database connection is properly closed.
|
|
412
359
|
"""
|
|
413
|
-
|
|
414
360
|
# If a database connection exists, close it and set the connection attribute to None
|
|
415
361
|
if self._conn:
|
|
416
362
|
self._conn.close()
|
|
@@ -421,25 +367,25 @@ class TestLogs(ITestLogs):
|
|
|
421
367
|
report: Dict
|
|
422
368
|
) -> bool:
|
|
423
369
|
"""
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
This method first checks for the existence of the reports table in the SQLite database,
|
|
427
|
-
creating it if necessary. It then attempts to insert the provided report dictionary into
|
|
428
|
-
the table. The report must contain all required fields as defined by the schema.
|
|
370
|
+
Insert a new test report into the database after ensuring the reports table exists.
|
|
429
371
|
|
|
430
372
|
Parameters
|
|
431
373
|
----------
|
|
432
|
-
report :
|
|
433
|
-
|
|
434
|
-
fields such as total_tests, passed, failed, errors, skipped, total_time, success_rate, and timestamp.
|
|
374
|
+
report : dict
|
|
375
|
+
Dictionary containing the test report data. Must include all required fields.
|
|
435
376
|
|
|
436
377
|
Returns
|
|
437
378
|
-------
|
|
438
379
|
bool
|
|
439
|
-
|
|
440
|
-
Raises an exception if the operation fails due to missing fields or database errors.
|
|
441
|
-
"""
|
|
380
|
+
True if the report was successfully inserted.
|
|
442
381
|
|
|
382
|
+
Raises
|
|
383
|
+
------
|
|
384
|
+
OrionisTestPersistenceError
|
|
385
|
+
If the operation fails due to database errors.
|
|
386
|
+
OrionisTestValueError
|
|
387
|
+
If required fields are missing from the report.
|
|
388
|
+
"""
|
|
443
389
|
# Ensure the reports table exists before inserting the report
|
|
444
390
|
self.__createTableIfNotExists()
|
|
445
391
|
|
|
@@ -450,20 +396,18 @@ class TestLogs(ITestLogs):
|
|
|
450
396
|
self
|
|
451
397
|
) -> bool:
|
|
452
398
|
"""
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
This method establishes a connection to the database and attempts to drop the table specified
|
|
456
|
-
by `self.__table_name` if it exists. This operation removes all stored test reports, resetting
|
|
457
|
-
the database to an empty state. If the table does not exist, the method completes without error.
|
|
458
|
-
If an error occurs during the operation, an OrionisTestPersistenceError is raised.
|
|
399
|
+
Drop the reports table from the SQLite database, clearing all test history records.
|
|
459
400
|
|
|
460
401
|
Returns
|
|
461
402
|
-------
|
|
462
403
|
bool
|
|
463
|
-
|
|
464
|
-
Raises an exception if the operation fails due to a database error.
|
|
465
|
-
"""
|
|
404
|
+
True if the reports table was successfully dropped or did not exist.
|
|
466
405
|
|
|
406
|
+
Raises
|
|
407
|
+
------
|
|
408
|
+
OrionisTestPersistenceError
|
|
409
|
+
If the operation fails due to a database error.
|
|
410
|
+
"""
|
|
467
411
|
# Attempt to drop the reports table and reset the database
|
|
468
412
|
return self.__resetDatabase()
|
|
469
413
|
|
|
@@ -473,26 +417,19 @@ class TestLogs(ITestLogs):
|
|
|
473
417
|
last: Optional[int] = None
|
|
474
418
|
) -> List[Tuple]:
|
|
475
419
|
"""
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
This method allows fetching either the earliest or latest test reports from the database.
|
|
479
|
-
If `first` is provided, it retrieves the earliest reports in ascending order by ID.
|
|
480
|
-
If `last` is provided, it retrieves the latest reports in descending order by ID.
|
|
481
|
-
Only one of `first` or `last` can be specified at a time; providing both will result in an error.
|
|
420
|
+
Retrieve test reports from the database.
|
|
482
421
|
|
|
483
422
|
Parameters
|
|
484
423
|
----------
|
|
485
|
-
first :
|
|
486
|
-
|
|
487
|
-
last :
|
|
488
|
-
|
|
424
|
+
first : int or None, optional
|
|
425
|
+
Number of earliest reports to retrieve, ordered by ascending ID.
|
|
426
|
+
last : int or None, optional
|
|
427
|
+
Number of latest reports to retrieve, ordered by descending ID.
|
|
489
428
|
|
|
490
429
|
Returns
|
|
491
430
|
-------
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
Each tuple contains all columns from the reports table, including the serialized JSON report
|
|
495
|
-
and associated statistics.
|
|
431
|
+
list of tuple
|
|
432
|
+
List of tuples representing report records.
|
|
496
433
|
|
|
497
434
|
Raises
|
|
498
435
|
------
|
|
@@ -501,6 +438,5 @@ class TestLogs(ITestLogs):
|
|
|
501
438
|
OrionisTestPersistenceError
|
|
502
439
|
If there is an error retrieving reports from the database.
|
|
503
440
|
"""
|
|
504
|
-
|
|
505
441
|
# Delegate the retrieval logic to the internal __getReports method
|
|
506
442
|
return self.__getReports(first, last)
|
|
@@ -5,20 +5,22 @@ class __ValidBasePath:
|
|
|
5
5
|
|
|
6
6
|
def __call__(self, base_path) -> Path:
|
|
7
7
|
"""
|
|
8
|
-
|
|
9
|
-
This validator ensures that the provided `base_path` is either a non-empty string or a `Path` object.
|
|
10
|
-
If valid, it returns a normalized `Path` object. Otherwise, it raises an `OrionisTestValueError`.
|
|
8
|
+
Validates and normalizes a base path.
|
|
11
9
|
|
|
12
10
|
Parameters
|
|
13
11
|
----------
|
|
14
12
|
base_path : str or Path
|
|
15
|
-
The base path to validate. Must be a non-empty string or a
|
|
13
|
+
The base path to validate. Must be a non-empty string or a Path object.
|
|
16
14
|
|
|
17
15
|
Returns
|
|
18
16
|
-------
|
|
19
17
|
Path
|
|
20
|
-
A normalized
|
|
21
|
-
|
|
18
|
+
A normalized Path object corresponding to the provided base path.
|
|
19
|
+
|
|
20
|
+
Raises
|
|
21
|
+
------
|
|
22
|
+
OrionisTestValueError
|
|
23
|
+
If `base_path` is not a non-empty string or a valid Path object.
|
|
22
24
|
"""
|
|
23
25
|
|
|
24
26
|
if isinstance(base_path, str):
|