orionis 0.283.0__py3-none-any.whl → 0.285.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/config/testing/entities/testing.py +25 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/asynchrony/{async_io.py → coroutines.py} +2 -1
- orionis/services/asynchrony/exceptions/__init__.py +0 -0
- orionis/services/asynchrony/exceptions/coroutine_exception.py +26 -0
- orionis/services/environment/dot_env.py +7 -7
- orionis/services/environment/env.py +56 -8
- orionis/services/environment/exceptions/__init__.py +0 -0
- orionis/services/environment/exceptions/value_exception.py +27 -0
- orionis/services/introspection/exceptions/__init__.py +0 -0
- orionis/services/introspection/exceptions/types.py +0 -0
- orionis/services/introspection/helpers/__init__.py +0 -0
- orionis/services/introspection/helpers/functions.py +285 -0
- orionis/services/introspection/reflection.py +216 -0
- orionis/services/parsers/exceptions/__init__.py +0 -0
- orionis/services/parsers/serializer.py +1 -1
- orionis/services/paths/exceptions/__init__.py +0 -0
- orionis/services/paths/exceptions/not_found_exceptions.py +28 -0
- orionis/services/paths/exceptions/path_value_exceptions.py +28 -0
- orionis/services/paths/resolver.py +6 -4
- orionis/services/standard/exceptions/__init__.py +0 -0
- orionis/services/standard/exceptions/path_value_exceptions.py +28 -0
- orionis/services/standard/std.py +4 -3
- orionis/test/entities/test_result.py +14 -1
- orionis/test/exceptions/test_persistence_error.py +34 -0
- orionis/test/exceptions/test_runtime_error.py +26 -0
- orionis/test/exceptions/test_value_error.py +26 -0
- orionis/test/logs/contracts/history.py +29 -56
- orionis/test/logs/history.py +309 -188
- orionis/test/output/contracts/dumper.py +24 -8
- orionis/test/output/dumper.py +52 -21
- orionis/test/suites/contracts/test_suite.py +27 -13
- orionis/test/suites/contracts/test_unit.py +101 -61
- orionis/test/suites/test_suite.py +45 -24
- orionis/test/suites/test_unit.py +559 -290
- orionis/unittesting.py +8 -0
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/METADATA +1 -1
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/RECORD +44 -26
- tests/services/asynchrony/test_async_io.py +3 -2
- /orionis/services/parsers/{exception.py → exceptions/exception_parser.py} +0 -0
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/WHEEL +0 -0
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/top_level.txt +0 -0
- {orionis-0.283.0.dist-info → orionis-0.285.0.dist-info}/zip-safe +0 -0
orionis/test/logs/history.py
CHANGED
@@ -1,251 +1,372 @@
|
|
1
1
|
import json
|
2
|
+
import re
|
2
3
|
import sqlite3
|
3
4
|
from pathlib import Path
|
4
|
-
from typing import Dict, List,
|
5
|
-
from contextlib import closing
|
5
|
+
from typing import Dict, List, Optional, Tuple
|
6
6
|
from orionis.services.environment.env import Env
|
7
|
+
from orionis.test.exceptions.test_persistence_error import OrionisTestPersistenceError
|
8
|
+
from orionis.test.exceptions.test_value_error import OrionisTestValueError
|
7
9
|
from orionis.test.logs.contracts.history import ITestHistory
|
8
10
|
|
9
11
|
class TestHistory(ITestHistory):
|
10
|
-
"""
|
11
|
-
A utility class for managing test execution reports using a local SQLite database.
|
12
|
-
|
13
|
-
Attributes
|
14
|
-
----------
|
15
|
-
TABLE_NAME : str
|
16
|
-
The name of the database table where reports are stored.
|
17
|
-
DB_NAME : str
|
18
|
-
The filename of the SQLite database.
|
19
|
-
FIELDS : List[str]
|
20
|
-
List of expected keys in the report dictionary.
|
21
|
-
_conn : sqlite3.Connection or None
|
22
|
-
SQLite database connection instance.
|
23
|
-
"""
|
24
|
-
|
25
|
-
TABLE_NAME = "reportes"
|
26
|
-
DB_NAME = "tests.sqlite"
|
27
|
-
FIELDS = [
|
28
|
-
"json", "total_tests", "passed", "failed", "errors",
|
29
|
-
"skipped", "total_time", "success_rate", "timestamp"
|
30
|
-
]
|
31
|
-
|
32
|
-
def __init__(self, test_db_path: Optional[str] = None) -> None:
|
33
|
-
"""
|
34
|
-
Initializes the class instance, setting up the path to the test database.
|
35
|
-
Parameters:
|
36
|
-
test_db_path (Optional[str]): Optional path to the test database file or directory. If a directory is provided, the database file name is appended. If not provided, the method checks the 'TEST_DB_PATH' environment variable, or defaults to a database file in the current file's directory.
|
37
|
-
Behavior:
|
38
|
-
- Resolves the database path to an absolute path.
|
39
|
-
- Ensures the parent directory for the database exists.
|
40
|
-
- Stores the resolved database path in the 'TEST_DB_PATH' environment variable.
|
41
|
-
- Prepares the instance for database connection initialization.
|
42
|
-
"""
|
43
|
-
|
44
|
-
if test_db_path:
|
45
|
-
|
46
|
-
# Resolve the provided test_db_path to an absolute path
|
47
|
-
db_path = Path(test_db_path).resolve()
|
48
|
-
|
49
|
-
# If the provided path is a directory, append the database name
|
50
|
-
if db_path.is_dir():
|
51
|
-
db_path = db_path / self.DB_NAME
|
52
12
|
|
53
|
-
|
13
|
+
def __init__(
|
14
|
+
self,
|
15
|
+
storage_path: Optional[str] = None,
|
16
|
+
db_name: Optional[str] = 'tests.sqlite',
|
17
|
+
table_name: Optional[str] = 'reports',
|
18
|
+
) -> None:
|
19
|
+
"""
|
20
|
+
Initialize the history storage for test logs.
|
54
21
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
22
|
+
Parameters
|
23
|
+
----------
|
24
|
+
storage_path : Optional[str], default=None
|
25
|
+
Directory path where the database file will be stored. If not provided,
|
26
|
+
the path is determined from the TEST_DB_PATH environment variable or
|
27
|
+
defaults to 'orionis/test/logs/storage' in the current working directory.
|
28
|
+
db_name : Optional[str], default='tests.sqlite'
|
29
|
+
Name of the SQLite database file. Must be alphanumeric or underscore and
|
30
|
+
end with '.sqlite'.
|
31
|
+
table_name : Optional[str], default='reports'
|
32
|
+
Name of the table to use in the database. Must be alphanumeric or underscore.
|
33
|
+
|
34
|
+
Raises
|
35
|
+
------
|
36
|
+
OrionisTestValueError
|
37
|
+
If db_name or table_name do not meet the required format.
|
38
|
+
"""
|
39
|
+
|
40
|
+
# Validate db_name: only alphanumeric and underscores, must end with .sqlite
|
41
|
+
if not isinstance(db_name, str) or not re.fullmatch(r'[a-zA-Z0-9_]+\.sqlite', db_name):
|
42
|
+
raise OrionisTestValueError("Database name must be alphanumeric/underscore and end with '.sqlite'.")
|
43
|
+
self.__db_name = db_name
|
61
44
|
|
62
|
-
|
45
|
+
# Validate table_name: only alphanumeric and underscores
|
46
|
+
if not isinstance(table_name, str) or not re.fullmatch(r'[a-zA-Z0-9_]+', table_name):
|
47
|
+
raise OrionisTestValueError("Table name must be alphanumeric/underscore only.")
|
48
|
+
self.__table_name = table_name
|
49
|
+
|
50
|
+
# Determine database path
|
51
|
+
db_path = None
|
52
|
+
if storage_path:
|
53
|
+
db_path = Path(storage_path).expanduser().resolve()
|
54
|
+
if db_path.is_dir():
|
55
|
+
db_path = db_path / self.__db_name
|
56
|
+
else:
|
57
|
+
env_path = Env.get(key="TEST_DB_PATH", default=None, is_path=True)
|
63
58
|
if env_path:
|
64
|
-
db_path = Path(env_path).resolve()
|
59
|
+
db_path = Path(env_path).expanduser().resolve()
|
65
60
|
if db_path.is_dir():
|
66
|
-
db_path = db_path / self.
|
61
|
+
db_path = db_path / self.__db_name
|
67
62
|
else:
|
68
|
-
db_path = Path(
|
63
|
+
db_path = Path.cwd() / 'storage/framework/testing' / self.__db_name
|
69
64
|
|
70
|
-
# Ensure directory exists
|
65
|
+
# Ensure parent directory exists
|
71
66
|
db_path.parent.mkdir(parents=True, exist_ok=True)
|
72
67
|
|
73
|
-
# Store
|
74
|
-
Env.set(
|
75
|
-
|
76
|
-
value=str(db_path),
|
77
|
-
is_path=True
|
78
|
-
)
|
68
|
+
# Store path in environment
|
69
|
+
Env.set(key="TEST_DB_PATH", value=str(db_path), is_path=True)
|
70
|
+
self.__db_path = db_path
|
79
71
|
|
80
|
-
#
|
72
|
+
# Create a connection to the database, initially set to None
|
81
73
|
self._conn: Optional[sqlite3.Connection] = None
|
82
74
|
|
83
75
|
def __connect(self) -> None:
|
84
76
|
"""
|
85
|
-
Establishes a connection to the SQLite database
|
86
|
-
'TEST_DB_PATH' environment variable. If the environment variable is not set,
|
87
|
-
raises a ConnectionError. If a connection error occurs during the attempt to
|
88
|
-
connect, raises a ConnectionError with the error details.
|
89
|
-
Raises:
|
90
|
-
ConnectionError: If the database path is not set or if a connection error occurs.
|
91
|
-
"""
|
77
|
+
Establishes a connection to the SQLite database if not already connected.
|
92
78
|
|
79
|
+
Attempts to create a new SQLite connection using the provided database path.
|
80
|
+
If the connection fails, raises an OrionisTestPersistenceError with the error details.
|
81
|
+
|
82
|
+
Raises
|
83
|
+
------
|
84
|
+
OrionisTestPersistenceError
|
85
|
+
If a database connection error occurs.
|
86
|
+
"""
|
93
87
|
if self._conn is None:
|
88
|
+
try:
|
89
|
+
self._conn = sqlite3.connect(str(self.__db_path))
|
90
|
+
except (sqlite3.Error, Exception) as e:
|
91
|
+
raise OrionisTestPersistenceError(f"Database connection error: {e}")
|
92
|
+
finally:
|
93
|
+
self._conn = None
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
default=None,
|
99
|
-
is_path=True
|
100
|
-
)
|
95
|
+
def __createTableIfNotExists(self) -> bool:
|
96
|
+
"""
|
97
|
+
Ensures that the test history table exists in the database.
|
101
98
|
|
102
|
-
|
103
|
-
|
104
|
-
raise ConnectionError("Database path is not set in environment variables.")
|
99
|
+
Connects to the database and creates the table with the required schema if it does not already exist.
|
100
|
+
Handles any SQLite errors by rolling back the transaction and raising a custom exception.
|
105
101
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
raise ConnectionError(f"Database connection error: {e}")
|
102
|
+
Raises
|
103
|
+
------
|
104
|
+
OrionisTestPersistenceError
|
105
|
+
If the table creation fails due to a database error.
|
111
106
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
with the schema defined by `self.TABLE_NAME`. The table includes columns for test
|
117
|
-
results and metadata such as total tests, passed, failed, errors, skipped, total time,
|
118
|
-
success rate, and timestamp. If the table already exists, no changes are made.
|
119
|
-
Raises a RuntimeError if the table creation fails due to a database error.
|
107
|
+
Returns
|
108
|
+
-------
|
109
|
+
bool
|
110
|
+
True if the table was created successfully or already exists, False otherwise.
|
120
111
|
"""
|
121
112
|
|
122
113
|
self.__connect()
|
123
114
|
try:
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
115
|
+
cursor = self._conn.cursor()
|
116
|
+
cursor.execute(f'''
|
117
|
+
CREATE TABLE IF NOT EXISTS {self.__table_name} (
|
118
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
119
|
+
json TEXT NOT NULL,
|
120
|
+
total_tests INTEGER,
|
121
|
+
passed INTEGER,
|
122
|
+
failed INTEGER,
|
123
|
+
errors INTEGER,
|
124
|
+
skipped INTEGER,
|
125
|
+
total_time REAL,
|
126
|
+
success_rate REAL,
|
127
|
+
timestamp TEXT
|
128
|
+
)
|
129
|
+
''')
|
139
130
|
self._conn.commit()
|
131
|
+
return True
|
140
132
|
except sqlite3.Error as e:
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
- failed
|
151
|
-
- errors
|
152
|
-
- skipped
|
153
|
-
- total_time
|
154
|
-
- success_rate
|
155
|
-
- timestamp
|
156
|
-
Raises:
|
157
|
-
ValueError: If any required report fields are missing.
|
158
|
-
RuntimeError: If there is an error inserting the report into the database.
|
133
|
+
if self._conn:
|
134
|
+
self._conn.rollback()
|
135
|
+
raise OrionisTestPersistenceError(f"Failed to create table: {e}")
|
136
|
+
finally:
|
137
|
+
if self._conn:
|
138
|
+
self.__close()
|
139
|
+
self._conn = None
|
140
|
+
|
141
|
+
def __insertReport(self, report: Dict) -> bool:
|
159
142
|
"""
|
143
|
+
Inserts a test report into the history database table.
|
160
144
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
145
|
+
Parameters
|
146
|
+
----------
|
147
|
+
report : Dict
|
148
|
+
A dictionary containing the report data. Must include the following keys:
|
149
|
+
- total_tests
|
150
|
+
- passed
|
151
|
+
- failed
|
152
|
+
- errors
|
153
|
+
- skipped
|
154
|
+
- total_time
|
155
|
+
- success_rate
|
156
|
+
- timestamp
|
165
157
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
173
|
-
''', (
|
174
|
-
json.dumps(report),
|
175
|
-
report["total_tests"],
|
176
|
-
report["passed"],
|
177
|
-
report["failed"],
|
178
|
-
report["errors"],
|
179
|
-
report["skipped"],
|
180
|
-
report["total_time"],
|
181
|
-
report["success_rate"],
|
182
|
-
report["timestamp"]
|
183
|
-
))
|
184
|
-
self._conn.commit()
|
185
|
-
except sqlite3.Error as e:
|
186
|
-
raise RuntimeError(f"Failed to insert report: {e}")
|
158
|
+
Raises
|
159
|
+
------
|
160
|
+
OrionisTestPersistenceError
|
161
|
+
If there is an error inserting the report into the database.
|
162
|
+
OrionisTestValueError
|
163
|
+
If required fields are missing from the report.
|
187
164
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
where (Optional[str]): SQL WHERE clause (without the 'WHERE' keyword).
|
193
|
-
params (Optional[Tuple]): Parameters to substitute in the WHERE clause.
|
194
|
-
Returns:
|
195
|
-
List[Tuple]: A list of tuples, each representing a row from the reports table.
|
196
|
-
Raises:
|
197
|
-
RuntimeError: If there is an error retrieving the reports from the database.
|
165
|
+
Returns
|
166
|
+
-------
|
167
|
+
bool
|
168
|
+
True if the report was successfully inserted, False otherwise.
|
198
169
|
"""
|
170
|
+
|
171
|
+
# Required fields in the report
|
172
|
+
fields = [
|
173
|
+
"json", "total_tests", "passed", "failed", "errors",
|
174
|
+
"skipped", "total_time", "success_rate", "timestamp"
|
175
|
+
]
|
176
|
+
|
177
|
+
# Validate report structure
|
178
|
+
missing = []
|
179
|
+
for key in fields:
|
180
|
+
if key not in report:
|
181
|
+
missing.append(key)
|
182
|
+
if missing:
|
183
|
+
raise OrionisTestValueError(f"Missing report fields: {missing}")
|
184
|
+
|
185
|
+
# Insert the report into the database
|
199
186
|
self.__connect()
|
200
187
|
try:
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
188
|
+
|
189
|
+
# Query to insert the report into the table
|
190
|
+
query = f'''
|
191
|
+
INSERT INTO {self.__table_name} (
|
192
|
+
json, total_tests, passed, failed, errors,
|
193
|
+
skipped, total_time, success_rate, timestamp
|
194
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
195
|
+
'''
|
196
|
+
|
197
|
+
# Execute the insert query with the report data
|
198
|
+
cursor = self._conn.cursor()
|
199
|
+
cursor.execute(query, (
|
200
|
+
json.dumps(report),
|
201
|
+
report["total_tests"],
|
202
|
+
report["passed"],
|
203
|
+
report["failed"],
|
204
|
+
report["errors"],
|
205
|
+
report["skipped"],
|
206
|
+
report["total_time"],
|
207
|
+
report["success_rate"],
|
208
|
+
report["timestamp"]
|
209
|
+
))
|
210
|
+
self._conn.commit()
|
211
|
+
return True
|
207
212
|
except sqlite3.Error as e:
|
208
|
-
|
213
|
+
if self._conn:
|
214
|
+
self._conn.rollback()
|
215
|
+
raise OrionisTestPersistenceError(f"Failed to insert report: {e}")
|
216
|
+
finally:
|
217
|
+
if self._conn:
|
218
|
+
self.__close()
|
219
|
+
self._conn = None
|
209
220
|
|
210
|
-
def
|
221
|
+
def __getReports(
|
222
|
+
self,
|
223
|
+
first: Optional[int] = None,
|
224
|
+
last: Optional[int] = None
|
225
|
+
) -> List[Tuple]:
|
211
226
|
"""
|
212
|
-
Retrieves
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
227
|
+
Retrieves a specified number of report records from the database, ordered by their ID.
|
228
|
+
|
229
|
+
Parameters
|
230
|
+
----------
|
231
|
+
first : Optional[int], default=None
|
232
|
+
The number of earliest reports to retrieve, ordered ascending by ID.
|
233
|
+
last : Optional[int], default=None
|
234
|
+
The number of latest reports to retrieve, ordered descending by ID.
|
235
|
+
|
236
|
+
Returns
|
237
|
+
-------
|
238
|
+
List[Tuple]
|
239
|
+
A list of tuples representing the report records.
|
240
|
+
|
241
|
+
Raises
|
242
|
+
------
|
243
|
+
OrionisTestValueError
|
244
|
+
If both 'first' and 'last' are specified, or if either is not a positive integer.
|
245
|
+
OrionisTestPersistenceError
|
246
|
+
If there is an error retrieving reports from the database.
|
217
247
|
"""
|
218
248
|
|
249
|
+
# Validate parameters
|
250
|
+
if first is not None and last is not None:
|
251
|
+
raise OrionisTestValueError(
|
252
|
+
"Cannot specify both 'first' and 'last' parameters. Use one or the other."
|
253
|
+
)
|
254
|
+
if first is not None:
|
255
|
+
if not isinstance(first, int) or first <= 0:
|
256
|
+
raise OrionisTestValueError("'first' must be an integer greater than 0.")
|
257
|
+
if last is not None:
|
258
|
+
if not isinstance(last, int) or last <= 0:
|
259
|
+
raise OrionisTestValueError("'last' must be an integer greater than 0.")
|
260
|
+
|
261
|
+
order = 'DESC' if last is not None else 'ASC'
|
262
|
+
quantity = first if first is not None else last
|
263
|
+
|
219
264
|
self.__connect()
|
220
265
|
try:
|
221
|
-
|
222
|
-
|
223
|
-
|
266
|
+
cursor = self._conn.cursor()
|
267
|
+
query = f"SELECT * FROM {self.__table_name} ORDER BY id {order} LIMIT ?"
|
268
|
+
cursor.execute(query, (quantity,))
|
269
|
+
results = cursor.fetchall()
|
270
|
+
return results
|
224
271
|
except sqlite3.Error as e:
|
225
|
-
raise
|
272
|
+
raise OrionisTestPersistenceError(f"Failed to retrieve reports from '{self.__db_name}': {e}")
|
273
|
+
finally:
|
274
|
+
if self._conn:
|
275
|
+
self.__close()
|
276
|
+
self._conn = None
|
226
277
|
|
227
|
-
def
|
278
|
+
def __resetDatabase(self) -> bool:
|
228
279
|
"""
|
229
|
-
Resets the database by dropping the table
|
230
|
-
This method
|
231
|
-
|
232
|
-
|
233
|
-
|
280
|
+
Resets the database by dropping the existing table.
|
281
|
+
This method connects to the database, drops the table specified by
|
282
|
+
`self.__table_name` if it exists, commits the changes, and then closes
|
283
|
+
the connection. If an error occurs during the process, an
|
284
|
+
OrionisTestPersistenceError is raised.
|
285
|
+
|
286
|
+
Raises
|
287
|
+
------
|
288
|
+
OrionisTestPersistenceError
|
289
|
+
If the database reset operation fails due to an SQLite error.
|
290
|
+
|
291
|
+
Returns
|
292
|
+
-------
|
293
|
+
bool
|
294
|
+
True if the database was successfully reset, False otherwise.
|
234
295
|
"""
|
235
296
|
|
236
297
|
self.__connect()
|
237
298
|
try:
|
238
|
-
|
239
|
-
|
299
|
+
cursor = self._conn.cursor()
|
300
|
+
cursor.execute(f'DROP TABLE IF EXISTS {self.__table_name}')
|
240
301
|
self._conn.commit()
|
302
|
+
return True
|
241
303
|
except sqlite3.Error as e:
|
242
|
-
raise
|
304
|
+
raise OrionisTestPersistenceError(f"Failed to reset database: {e}")
|
305
|
+
finally:
|
306
|
+
if self._conn:
|
307
|
+
self.__close()
|
308
|
+
self._conn = None
|
243
309
|
|
244
|
-
def
|
310
|
+
def __close(self) -> None:
|
245
311
|
"""
|
246
|
-
Closes the current database connection
|
312
|
+
Closes the current database connection.
|
313
|
+
This method checks if a database connection exists. If so, it closes the connection and sets the connection attribute to None.
|
314
|
+
|
315
|
+
Returns
|
316
|
+
-------
|
317
|
+
None
|
247
318
|
"""
|
248
319
|
|
249
320
|
if self._conn:
|
250
321
|
self._conn.close()
|
251
322
|
self._conn = None
|
323
|
+
|
324
|
+
def create(self, report: Dict) -> bool:
|
325
|
+
"""
|
326
|
+
Create a new test report in the history database.
|
327
|
+
|
328
|
+
Parameters
|
329
|
+
----------
|
330
|
+
report : Dict
|
331
|
+
A dictionary containing the test report data.
|
332
|
+
|
333
|
+
Returns
|
334
|
+
-------
|
335
|
+
bool
|
336
|
+
True if the report was successfully created, False otherwise.
|
337
|
+
"""
|
338
|
+
self.__createTableIfNotExists()
|
339
|
+
return self.__insertReport(report)
|
340
|
+
|
341
|
+
def reset(self) -> bool:
|
342
|
+
"""
|
343
|
+
Reset the history database by dropping the existing table.
|
344
|
+
|
345
|
+
Returns
|
346
|
+
-------
|
347
|
+
bool
|
348
|
+
True if the database was successfully reset, False otherwise.
|
349
|
+
"""
|
350
|
+
return self.__resetDatabase()
|
351
|
+
|
352
|
+
def get(
|
353
|
+
self,
|
354
|
+
first: Optional[int] = None,
|
355
|
+
last: Optional[int] = None
|
356
|
+
) -> List[Tuple]:
|
357
|
+
"""
|
358
|
+
Retrieve test reports from the history database.
|
359
|
+
|
360
|
+
Parameters
|
361
|
+
----------
|
362
|
+
first : Optional[int], default=None
|
363
|
+
The number of earliest reports to retrieve, ordered ascending by ID.
|
364
|
+
last : Optional[int], default=None
|
365
|
+
The number of latest reports to retrieve, ordered descending by ID.
|
366
|
+
|
367
|
+
Returns
|
368
|
+
-------
|
369
|
+
List[Tuple]
|
370
|
+
A list of tuples representing the retrieved reports.
|
371
|
+
"""
|
372
|
+
return self.__getReports(first, last)
|
@@ -3,27 +3,43 @@ from abc import ABC, abstractmethod
|
|
3
3
|
class ITestDumper(ABC):
|
4
4
|
"""
|
5
5
|
Interface for standard output debugging utilities.
|
6
|
-
|
6
|
+
|
7
|
+
This interface defines methods for dumping debugging information,
|
8
|
+
capturing the caller's file, method, and line number, and utilizing
|
9
|
+
a Debug class to output the information.
|
10
|
+
|
11
|
+
Implementations
|
12
|
+
--------------
|
13
|
+
Implementations should provide mechanisms to output or log the
|
14
|
+
provided arguments for debugging purposes.
|
7
15
|
"""
|
8
16
|
|
9
17
|
@abstractmethod
|
10
|
-
def dd(self, *args):
|
18
|
+
def dd(self, *args) -> None:
|
11
19
|
"""
|
12
20
|
Dumps debugging information using the Debug class.
|
13
|
-
|
21
|
+
|
22
|
+
This method captures the caller's file and line number,
|
14
23
|
and uses the Debug class to output debugging information.
|
15
|
-
|
16
|
-
|
24
|
+
|
25
|
+
Parameters
|
26
|
+
----------
|
27
|
+
*args : tuple
|
28
|
+
Variable length argument list to be dumped.
|
17
29
|
"""
|
18
30
|
pass
|
19
31
|
|
20
32
|
@abstractmethod
|
21
|
-
def dump(self, *args):
|
33
|
+
def dump(self, *args) -> None:
|
22
34
|
"""
|
23
35
|
Dumps debugging information using the Debug class.
|
36
|
+
|
24
37
|
This method captures the caller's file, method, and line number,
|
25
38
|
and uses the Debug class to output debugging information.
|
26
|
-
|
27
|
-
|
39
|
+
|
40
|
+
Parameters
|
41
|
+
----------
|
42
|
+
*args : tuple
|
43
|
+
Variable length argument list to be dumped.
|
28
44
|
"""
|
29
45
|
pass
|