PyTestLog2DB 0.2.7__tar.gz → 0.3.0__tar.gz
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.
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PKG-INFO +5 -3
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/PyTestLog2DB.pdf +0 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/__init__.py +2 -2
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/__main__.py +2 -2
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/pytestlog2db.py +53 -51
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/version.py +3 -3
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB.egg-info/PKG-INFO +5 -3
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB.egg-info/SOURCES.txt +0 -1
- PyTestLog2DB-0.3.0/PyTestLog2DB.egg-info/requires.txt +3 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/README.rst +22 -20
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/setup.py +1 -1
- PyTestLog2DB-0.2.7/PyTestLog2DB/CDataBase.py +0 -1502
- PyTestLog2DB-0.2.7/PyTestLog2DB.egg-info/requires.txt +0 -3
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/LICENSE +0 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB/xsd/junit.xsd +0 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB.egg-info/dependency_links.txt +0 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/PyTestLog2DB.egg-info/top_level.txt +0 -0
- {PyTestLog2DB-0.2.7 → PyTestLog2DB-0.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyTestLog2DB
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Imports pytest result(s) to TestResultWebApp database
|
|
5
5
|
Home-page: https://github.com/test-fullautomation/python-pytestlog2db
|
|
6
6
|
Author: Tran Duy Ngoan
|
|
@@ -134,7 +134,7 @@ Use below command to get tools\'s usage
|
|
|
134
134
|
|
|
135
135
|
The usage should be showed as below:
|
|
136
136
|
|
|
137
|
-
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
137
|
+
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
138
138
|
resultxmlfile server user password database
|
|
139
139
|
|
|
140
140
|
PyTestLog2DB imports pytest JUnit XML report file(s)generated by pytest into a WebApp database.
|
|
@@ -156,6 +156,8 @@ The usage should be showed as below:
|
|
|
156
156
|
--variant VARIANT variant name to be set for this import.
|
|
157
157
|
--versions VERSIONS metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).
|
|
158
158
|
--config CONFIG configuration json file for component mapping information.
|
|
159
|
+
--interface {db,rest}
|
|
160
|
+
database access interface.
|
|
159
161
|
|
|
160
162
|
The below command is simple usage with all required arguments to import
|
|
161
163
|
[pytest](https://docs.pytest.org) results into TestResultWebApp\'s
|
|
@@ -285,7 +287,7 @@ About
|
|
|
285
287
|
|
|
286
288
|
### License
|
|
287
289
|
|
|
288
|
-
Copyright 2020-
|
|
290
|
+
Copyright 2020-2023 Robert Bosch GmbH
|
|
289
291
|
|
|
290
292
|
Licensed under the Apache License, Version 2.0 (the \"License\"); you
|
|
291
293
|
may not use this file except in compliance with the License. You may
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2023 Robert Bosch GmbH
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
13
|
+
# limitations under the License.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2023 Robert Bosch GmbH
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
from PyTestLog2DB.pytestlog2db import PyTestLog2DB
|
|
15
15
|
|
|
16
16
|
if __name__ == "__main__":
|
|
17
|
-
PyTestLog2DB()
|
|
17
|
+
PyTestLog2DB()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2023 Robert Bosch GmbH
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
#lxml
|
|
20
20
|
# This tool is used to parse the pytest JUnit XML report file(s)
|
|
21
21
|
# then import them into TestResultWebApp's database
|
|
22
|
-
#
|
|
22
|
+
#
|
|
23
23
|
# History:
|
|
24
|
-
#
|
|
24
|
+
#
|
|
25
25
|
# 2022-11-22:
|
|
26
26
|
# - initial version
|
|
27
27
|
#
|
|
@@ -37,10 +37,10 @@ import colorama as col
|
|
|
37
37
|
import json
|
|
38
38
|
from lxml import etree
|
|
39
39
|
from datetime import datetime, timedelta
|
|
40
|
-
import platform
|
|
40
|
+
import platform
|
|
41
41
|
from pkg_resources import get_distribution
|
|
42
42
|
|
|
43
|
-
from
|
|
43
|
+
from TestResultDBAccess import DBAccessFactory
|
|
44
44
|
from PyTestLog2DB.version import VERSION, VERSION_DATE
|
|
45
45
|
|
|
46
46
|
PYTEST_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
|
@@ -57,7 +57,7 @@ This information is used as default value for `tester` when importing.
|
|
|
57
57
|
|
|
58
58
|
**Returns:**
|
|
59
59
|
|
|
60
|
-
* ``sUserName``
|
|
60
|
+
* ``sUserName``
|
|
61
61
|
|
|
62
62
|
/ *Type*: str /
|
|
63
63
|
|
|
@@ -76,17 +76,17 @@ This information is used as default value for `tester` when importing.
|
|
|
76
76
|
try:
|
|
77
77
|
GetUserNameEx = ctypes.windll.secur32.GetUserNameExW
|
|
78
78
|
NameDisplay = 3
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
size = ctypes.pointer(ctypes.c_ulong(0))
|
|
81
81
|
GetUserNameEx(NameDisplay, None, size)
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
nameBuffer = ctypes.create_unicode_buffer(size.contents.value)
|
|
84
84
|
GetUserNameEx(NameDisplay, nameBuffer, size)
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
sUserName=nameBuffer.value
|
|
87
87
|
except:
|
|
88
88
|
pass
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
return sUserName
|
|
91
91
|
|
|
92
92
|
def __curent_testtool():
|
|
@@ -220,7 +220,7 @@ Write log message to console/file output.
|
|
|
220
220
|
/ *Condition*: optional / *Type*: int / *Default*: 0 /
|
|
221
221
|
|
|
222
222
|
Offset indent.
|
|
223
|
-
|
|
223
|
+
|
|
224
224
|
**Returns:**
|
|
225
225
|
|
|
226
226
|
(*no returns*)
|
|
@@ -238,7 +238,7 @@ Write log message to console/file output.
|
|
|
238
238
|
def log_warning(cls, msg):
|
|
239
239
|
"""
|
|
240
240
|
Write warning message to console/file output.
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
**Arguments:**
|
|
243
243
|
|
|
244
244
|
* ``msg``
|
|
@@ -304,6 +304,7 @@ Avalable arguments in command line:
|
|
|
304
304
|
- `--variant` : variant name to be set for this import.
|
|
305
305
|
- `--versions` : metadata: Versions (Software;Hardware;Test) to be set for this import.
|
|
306
306
|
- `--config` : configuration json file for component mapping information.
|
|
307
|
+
- `--interface` : database access interface.
|
|
307
308
|
|
|
308
309
|
**Arguments:**
|
|
309
310
|
|
|
@@ -315,7 +316,7 @@ Avalable arguments in command line:
|
|
|
315
316
|
|
|
316
317
|
ArgumentParser object.
|
|
317
318
|
"""
|
|
318
|
-
cmdlineparser=argparse.ArgumentParser(prog="PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer)",
|
|
319
|
+
cmdlineparser=argparse.ArgumentParser(prog="PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer)",
|
|
319
320
|
description="PyTestLog2DB imports pytest JUnit XML report file(s)" + \
|
|
320
321
|
"generated by pytest into a WebApp database."
|
|
321
322
|
)
|
|
@@ -335,6 +336,7 @@ Avalable arguments in command line:
|
|
|
335
336
|
cmdlineparser.add_argument('--variant', type=str, help='variant name to be set for this import.')
|
|
336
337
|
cmdlineparser.add_argument('--versions', type=str, help='metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).')
|
|
337
338
|
cmdlineparser.add_argument('--config', type=str, help='configuration json file for component mapping information.')
|
|
339
|
+
cmdlineparser.add_argument('--interface', choices=['db', 'rest'], default='db', help='database access interface.')
|
|
338
340
|
|
|
339
341
|
return cmdlineparser.parse_args()
|
|
340
342
|
|
|
@@ -347,13 +349,13 @@ Collect all valid Robot xml result file in given path.
|
|
|
347
349
|
* ``path``
|
|
348
350
|
|
|
349
351
|
/ *Condition*: required / *Type*: str /
|
|
350
|
-
|
|
352
|
+
|
|
351
353
|
Path to Robot result folder or file to be searched.
|
|
352
354
|
|
|
353
355
|
* ``search_recursive``
|
|
354
356
|
|
|
355
357
|
/ *Condition*: optional / *Type*: bool / *Default*: False /
|
|
356
|
-
|
|
358
|
+
|
|
357
359
|
If set, the given path is searched recursively for xml result files.
|
|
358
360
|
|
|
359
361
|
**Returns:**
|
|
@@ -405,19 +407,19 @@ Verify the given xml result file is valid or not.
|
|
|
405
407
|
* ``xml_result``
|
|
406
408
|
|
|
407
409
|
/ *Condition*: required / *Type*: str /
|
|
408
|
-
|
|
410
|
+
|
|
409
411
|
Path to PyTest result file.
|
|
410
412
|
|
|
411
413
|
* ``xsd_schema``
|
|
412
414
|
|
|
413
415
|
/ *Condition*: optional / *Type*: str / *Default*: <installed_folder>\/xsd\/junit.xsd /
|
|
414
|
-
|
|
416
|
+
|
|
415
417
|
Path to Robot schema *.xsd file.
|
|
416
418
|
|
|
417
419
|
* ``exit_on_failure``
|
|
418
420
|
|
|
419
421
|
/ *Condition*: optional / *Type*: bool / *Default*: True /
|
|
420
|
-
|
|
422
|
+
|
|
421
423
|
If set, exit with fatal error if the schema validation of given xml file failed.
|
|
422
424
|
|
|
423
425
|
**Returns:**
|
|
@@ -452,13 +454,13 @@ Verify the given UUID is valid or not.
|
|
|
452
454
|
* ``uuid_to_test``
|
|
453
455
|
|
|
454
456
|
/ *Condition*: required / *Type*: str /
|
|
455
|
-
|
|
457
|
+
|
|
456
458
|
UUID to be verified.
|
|
457
459
|
|
|
458
460
|
* ``version``
|
|
459
461
|
|
|
460
462
|
/ *Condition*: optional / *Type*: int / *Default*: 4 /
|
|
461
|
-
|
|
463
|
+
|
|
462
464
|
UUID version.
|
|
463
465
|
|
|
464
466
|
**Returns:**
|
|
@@ -474,10 +476,10 @@ Verify the given UUID is valid or not.
|
|
|
474
476
|
uuid_obj = uuid.UUID(uuid_to_test, version=version)
|
|
475
477
|
except:
|
|
476
478
|
return bValid
|
|
477
|
-
|
|
479
|
+
|
|
478
480
|
if str(uuid_obj) == uuid_to_test:
|
|
479
481
|
bValid = True
|
|
480
|
-
|
|
482
|
+
|
|
481
483
|
return bValid
|
|
482
484
|
|
|
483
485
|
def is_valid_config(dConfig, dSchema=CONFIG_SCHEMA, bExitOnFail=True):
|
|
@@ -546,7 +548,7 @@ Default schema supports below information:
|
|
|
546
548
|
bValid = False
|
|
547
549
|
Logger.log_error(f"Invalid key '{key}' in configuration json file.", fatal_error=bExitOnFail)
|
|
548
550
|
break
|
|
549
|
-
|
|
551
|
+
|
|
550
552
|
return bValid
|
|
551
553
|
|
|
552
554
|
|
|
@@ -597,7 +599,7 @@ Besides, `starttime` and `endtime` are also calculated and added in the merged r
|
|
|
597
599
|
|
|
598
600
|
except Exception as reason:
|
|
599
601
|
Logger.log_error(f"Error when merging pytest xml files. Reason: {reason}", fatal_error=True)
|
|
600
|
-
|
|
602
|
+
|
|
601
603
|
# Additional attributes for testsuites
|
|
602
604
|
oMergedTree.attrib["starttime"] = datetime.strftime(dtStartTime, DB_DATETIME_FORMAT)
|
|
603
605
|
oMergedTree.attrib["endtime"] = datetime.strftime(dtEndTime, DB_DATETIME_FORMAT)
|
|
@@ -610,18 +612,18 @@ Get branch name from software version information.
|
|
|
610
612
|
|
|
611
613
|
Convention of branch information in suffix of software version:
|
|
612
614
|
|
|
613
|
-
* All software version with .0F is the main/freature branch.
|
|
615
|
+
* All software version with .0F is the main/freature branch.
|
|
614
616
|
The leading number is the current year. E.g. ``17.0F03``
|
|
615
|
-
* All software version with ``.1S``, ``.2S``, ... is a stabi branch.
|
|
617
|
+
* All software version with ``.1S``, ``.2S``, ... is a stabi branch.
|
|
616
618
|
The leading number is the year of branching out for stabilization.
|
|
617
619
|
The number before "S" is the order of branching out in the year.
|
|
618
|
-
|
|
620
|
+
|
|
619
621
|
**Arguments:**
|
|
620
622
|
|
|
621
623
|
* ``sw_version``
|
|
622
624
|
|
|
623
625
|
/ *Condition*: required / *Type*: str /
|
|
624
|
-
|
|
626
|
+
|
|
625
627
|
Software version.
|
|
626
628
|
|
|
627
629
|
**Returns:**
|
|
@@ -738,7 +740,7 @@ def process_config_file(config_file):
|
|
|
738
740
|
Parse information from configuration file:
|
|
739
741
|
|
|
740
742
|
* ``component``:
|
|
741
|
-
|
|
743
|
+
|
|
742
744
|
.. code:: python
|
|
743
745
|
|
|
744
746
|
{
|
|
@@ -752,7 +754,7 @@ Parse information from configuration file:
|
|
|
752
754
|
}
|
|
753
755
|
}
|
|
754
756
|
|
|
755
|
-
Then all testcases which their paths contain ``componentA/path/to/testcase``
|
|
757
|
+
Then all testcases which their paths contain ``componentA/path/to/testcase``
|
|
756
758
|
will be belong to ``componentA``, ...
|
|
757
759
|
|
|
758
760
|
**Arguments:**
|
|
@@ -768,7 +770,7 @@ Parse information from configuration file:
|
|
|
768
770
|
* ``dConfig``
|
|
769
771
|
|
|
770
772
|
/ *Type*: dict /
|
|
771
|
-
|
|
773
|
+
|
|
772
774
|
Configuration object.
|
|
773
775
|
"""
|
|
774
776
|
|
|
@@ -858,12 +860,12 @@ Process test case data and create new test case record.
|
|
|
858
860
|
Logger.log_error(f"Error when getting PyTest result of test '{_tbl_case_name}'. Reason: {reason}", fatal_error=True)
|
|
859
861
|
return
|
|
860
862
|
|
|
861
|
-
_tbl_case_result_state = "complete"
|
|
863
|
+
_tbl_case_result_state = "complete"
|
|
862
864
|
_tbl_case_result_return = 11
|
|
863
865
|
_tbl_case_counter_resets = 0
|
|
864
866
|
_tbl_test_result_id = test_result_id
|
|
865
867
|
_tbl_file_id = file_id
|
|
866
|
-
|
|
868
|
+
|
|
867
869
|
if not Logger.dryrun:
|
|
868
870
|
try:
|
|
869
871
|
tbl_case_id = db.nCreateNewSingleTestCase(_tbl_case_name,
|
|
@@ -884,7 +886,7 @@ Process test case data and create new test case record.
|
|
|
884
886
|
)
|
|
885
887
|
except Exception as reason:
|
|
886
888
|
Logger.log_error(f"Cannot create new test case result for test '{_tbl_case_name}' in database.\nReason: {reason}")
|
|
887
|
-
return
|
|
889
|
+
return float(test.get("time"))
|
|
888
890
|
else:
|
|
889
891
|
tbl_case_id = "testcase id for dryrun"
|
|
890
892
|
iSuccessTestcase += 1
|
|
@@ -929,7 +931,7 @@ Process to the lowest suite level (test file):
|
|
|
929
931
|
|
|
930
932
|
**Returns:**
|
|
931
933
|
|
|
932
|
-
(*no returns*)
|
|
934
|
+
(*no returns*)
|
|
933
935
|
"""
|
|
934
936
|
|
|
935
937
|
# File metadata
|
|
@@ -980,7 +982,7 @@ Process to the lowest suite level (test file):
|
|
|
980
982
|
|
|
981
983
|
_tbl_header_testrequirements_documentmanagement = ""
|
|
982
984
|
_tbl_header_testrequirements_testenvironment = ""
|
|
983
|
-
|
|
985
|
+
|
|
984
986
|
_tbl_header_testbenchconfig_name = ""
|
|
985
987
|
_tbl_header_testbenchconfig_data = ""
|
|
986
988
|
_tbl_header_preprocessor_filter = ""
|
|
@@ -1024,7 +1026,7 @@ Process to the lowest suite level (test file):
|
|
|
1024
1026
|
_tbl_header_testbenchconfig_name,
|
|
1025
1027
|
_tbl_header_testbenchconfig_data,
|
|
1026
1028
|
_tbl_header_preprocessor_filter,
|
|
1027
|
-
_tbl_header_preprocessor_parameters
|
|
1029
|
+
_tbl_header_preprocessor_parameters
|
|
1028
1030
|
)
|
|
1029
1031
|
except Exception as reason:
|
|
1030
1032
|
Logger.log_error(f"Cannot create new test file result for file '{_tbl_file_name}' in database.\nReason: {reason}",
|
|
@@ -1033,7 +1035,7 @@ Process to the lowest suite level (test file):
|
|
|
1033
1035
|
_tbl_file_id = "file id for dryrun"
|
|
1034
1036
|
Logger.log(f"Created test file result for classname '{_tbl_file_name}' successfully: {str(_tbl_file_id)}", indent=2)
|
|
1035
1037
|
previous_file_name = _tbl_file_name
|
|
1036
|
-
|
|
1038
|
+
|
|
1037
1039
|
# Process testcase
|
|
1038
1040
|
if _tbl_file_id:
|
|
1039
1041
|
duration = process_test(db, test, _tbl_file_id, _tbl_test_result_id, component_name, test_number, test_start_time)
|
|
@@ -1046,7 +1048,7 @@ def PyTestLog2DB(args=None):
|
|
|
1046
1048
|
"""
|
|
1047
1049
|
Import pytest results from ``*.xml`` file(s) to TestResultWebApp's database.
|
|
1048
1050
|
|
|
1049
|
-
Flow to import PyTest results to database:
|
|
1051
|
+
Flow to import PyTest results to database:
|
|
1050
1052
|
|
|
1051
1053
|
1. Process provided arguments from command line.
|
|
1052
1054
|
2. Parse PyTest results.
|
|
@@ -1101,7 +1103,7 @@ Flow to import PyTest results to database:
|
|
|
1101
1103
|
arVersions=args.versions.split(";")
|
|
1102
1104
|
arVersions=[x.strip() for x in arVersions]
|
|
1103
1105
|
if len(arVersions)>3:
|
|
1104
|
-
Logger.log_error(f"The provided versions information is not valid: '{str(args.versions)}'",
|
|
1106
|
+
Logger.log_error(f"The provided versions information is not valid: '{str(args.versions)}'",
|
|
1105
1107
|
fatal_error=True)
|
|
1106
1108
|
|
|
1107
1109
|
# Validate provided configuration file (component, variant, version_sw)
|
|
@@ -1119,7 +1121,7 @@ Flow to import PyTest results to database:
|
|
|
1119
1121
|
|
|
1120
1122
|
|
|
1121
1123
|
# 3. Connect to database
|
|
1122
|
-
db=
|
|
1124
|
+
db = DBAccessFactory().create(args.interface)
|
|
1123
1125
|
try:
|
|
1124
1126
|
db.connect(args.server,
|
|
1125
1127
|
args.user,
|
|
@@ -1134,12 +1136,12 @@ Flow to import PyTest results to database:
|
|
|
1134
1136
|
# |
|
|
1135
1137
|
# '---Create new file result(s)
|
|
1136
1138
|
# |
|
|
1137
|
-
# '---Create new test result(s)
|
|
1139
|
+
# '---Create new test result(s)
|
|
1138
1140
|
try:
|
|
1139
1141
|
bUseDefaultPrjVariant = True
|
|
1140
1142
|
bUseDefaultVersionSW = True
|
|
1141
1143
|
sMsgVarirantSetBy = sMsgVersionSWSetBy = "default value"
|
|
1142
|
-
|
|
1144
|
+
|
|
1143
1145
|
# Process project/variant
|
|
1144
1146
|
sVariant = dConfig["variant"]
|
|
1145
1147
|
if args.variant!=None and args.variant.strip() != "":
|
|
@@ -1148,7 +1150,7 @@ Flow to import PyTest results to database:
|
|
|
1148
1150
|
sVariant = args.variant.strip()
|
|
1149
1151
|
elif sVariant != DEFAULT_METADATA["variant"]:
|
|
1150
1152
|
bUseDefaultPrjVariant = False
|
|
1151
|
-
sMsgVarirantSetBy = f"from configuration '{args.config}' file provided by --config"
|
|
1153
|
+
sMsgVarirantSetBy = f"from configuration '{args.config}' file provided by --config"
|
|
1152
1154
|
_tbl_prj_project = _tbl_prj_variant = sVariant
|
|
1153
1155
|
|
|
1154
1156
|
# Process versions info
|
|
@@ -1162,7 +1164,7 @@ Flow to import PyTest results to database:
|
|
|
1162
1164
|
bUseDefaultVersionSW = False
|
|
1163
1165
|
sMsgVersionSWSetBy = "from --versions commandline argument"
|
|
1164
1166
|
if len(arVersions)==1 or len(arVersions)==2 or len(arVersions)==3:
|
|
1165
|
-
sVersionSW = arVersions[0]
|
|
1167
|
+
sVersionSW = arVersions[0]
|
|
1166
1168
|
if len(arVersions)==2 or len(arVersions)==3:
|
|
1167
1169
|
sVersionHW = arVersions[1]
|
|
1168
1170
|
if len(arVersions)==3:
|
|
@@ -1190,7 +1192,7 @@ Flow to import PyTest results to database:
|
|
|
1190
1192
|
_tbl_test_result_id = str(uuid.uuid4())
|
|
1191
1193
|
if args.append:
|
|
1192
1194
|
Logger.log_error("'--append' argument should be used in combination with '--UUID <UUID>` argument.", fatal_error=True)
|
|
1193
|
-
|
|
1195
|
+
|
|
1194
1196
|
# Process start/end time info
|
|
1195
1197
|
_tbl_result_time_start = pytest_result.get("starttime")
|
|
1196
1198
|
_tbl_result_time_end = pytest_result.get("endtime")
|
|
@@ -1210,20 +1212,20 @@ Flow to import PyTest results to database:
|
|
|
1210
1212
|
_db_version_sw = _db_result_info[1]
|
|
1211
1213
|
if not bUseDefaultPrjVariant and _tbl_prj_variant != _db_prj_variant:
|
|
1212
1214
|
Logger.log_error(f"Given project/variant '{_tbl_prj_variant}' ({sMsgVarirantSetBy}) is different with existing value '{_db_prj_variant}' in database.", fatal_error=True)
|
|
1213
|
-
elif not bUseDefaultVersionSW and _tbl_result_version_sw_target != _db_version_sw:
|
|
1215
|
+
elif not bUseDefaultVersionSW and _tbl_result_version_sw_target != _db_version_sw:
|
|
1214
1216
|
Logger.log_error(f"Given version software '{_tbl_result_version_sw_target}' ({sMsgVersionSWSetBy}) is different with existing value '{_db_version_sw}' in database.", fatal_error=True)
|
|
1215
1217
|
else:
|
|
1216
1218
|
Logger.log(f"Append to existing test execution result for variant '{_db_prj_variant}' - version '{_db_version_sw}' - UUID '{_tbl_test_result_id}'.")
|
|
1217
1219
|
else:
|
|
1218
1220
|
Logger.log_error(f"Execution result with UUID '{_tbl_test_result_id}' is already existing. \
|
|
1219
1221
|
\n{error_indent}Please use other UUID (or remove '--UUID' argument from your command) for new execution result. \
|
|
1220
|
-
\n{error_indent}Or add '--append' argument in your command to append new result(s) to this existing UUID.",
|
|
1222
|
+
\n{error_indent}Or add '--append' argument in your command to append new result(s) to this existing UUID.",
|
|
1221
1223
|
fatal_error=True)
|
|
1222
1224
|
else:
|
|
1223
1225
|
if args.append:
|
|
1224
1226
|
Logger.log_error(f"Execution result with UUID '{_tbl_test_result_id}' is not existing for appending.\
|
|
1225
1227
|
\n{error_indent}Please use an existing UUID to append new result(s) to that UUID. \
|
|
1226
|
-
\n{error_indent}Or remove '--append' argument in your command to create new execution result with given UUID.",
|
|
1228
|
+
\n{error_indent}Or remove '--append' argument in your command to create new execution result with given UUID.",
|
|
1227
1229
|
fatal_error=True)
|
|
1228
1230
|
else:
|
|
1229
1231
|
# Process new test result
|
|
@@ -1256,8 +1258,8 @@ Flow to import PyTest results to database:
|
|
|
1256
1258
|
# 5. Disconnect from database
|
|
1257
1259
|
db.disconnect()
|
|
1258
1260
|
import_mode_msg = "appended" if args.append else "written"
|
|
1259
|
-
testcnt_msg = f"All {iTotalTestcase}"
|
|
1260
|
-
extended_msg = ""
|
|
1261
|
+
testcnt_msg = f"All {iTotalTestcase}"
|
|
1262
|
+
extended_msg = ""
|
|
1261
1263
|
if (iTotalTestcase>iSuccessTestcase):
|
|
1262
1264
|
testcnt_msg = f"{iSuccessTestcase} of {iTotalTestcase}"
|
|
1263
1265
|
extended_msg = f" {iTotalTestcase-iSuccessTestcase} test cases are skipped because of errors."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# **************************************************************************************************************
|
|
2
2
|
#
|
|
3
|
-
# Copyright 2020-
|
|
3
|
+
# Copyright 2020-2023 Robert Bosch GmbH
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
#
|
|
19
19
|
# Version and date of PyTestLog2DB
|
|
20
20
|
#
|
|
21
|
-
VERSION = "0.
|
|
22
|
-
VERSION_DATE = "
|
|
21
|
+
VERSION = "0.3.0"
|
|
22
|
+
VERSION_DATE = "07.05.2024"
|
|
23
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyTestLog2DB
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Imports pytest result(s) to TestResultWebApp database
|
|
5
5
|
Home-page: https://github.com/test-fullautomation/python-pytestlog2db
|
|
6
6
|
Author: Tran Duy Ngoan
|
|
@@ -134,7 +134,7 @@ Use below command to get tools\'s usage
|
|
|
134
134
|
|
|
135
135
|
The usage should be showed as below:
|
|
136
136
|
|
|
137
|
-
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
137
|
+
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
138
138
|
resultxmlfile server user password database
|
|
139
139
|
|
|
140
140
|
PyTestLog2DB imports pytest JUnit XML report file(s)generated by pytest into a WebApp database.
|
|
@@ -156,6 +156,8 @@ The usage should be showed as below:
|
|
|
156
156
|
--variant VARIANT variant name to be set for this import.
|
|
157
157
|
--versions VERSIONS metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).
|
|
158
158
|
--config CONFIG configuration json file for component mapping information.
|
|
159
|
+
--interface {db,rest}
|
|
160
|
+
database access interface.
|
|
159
161
|
|
|
160
162
|
The below command is simple usage with all required arguments to import
|
|
161
163
|
[pytest](https://docs.pytest.org) results into TestResultWebApp\'s
|
|
@@ -285,7 +287,7 @@ About
|
|
|
285
287
|
|
|
286
288
|
### License
|
|
287
289
|
|
|
288
|
-
Copyright 2020-
|
|
290
|
+
Copyright 2020-2023 Robert Bosch GmbH
|
|
289
291
|
|
|
290
292
|
Licensed under the Apache License, Version 2.0 (the \"License\"); you
|
|
291
293
|
may not use this file except in compliance with the License. You may
|
|
@@ -17,15 +17,15 @@ Table of Contents
|
|
|
17
17
|
- `Maintainers <#maintainers>`__
|
|
18
18
|
- `Contributors <#contributors>`__
|
|
19
19
|
- `License <#license>`__
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
Getting Started
|
|
22
22
|
---------------
|
|
23
23
|
|
|
24
|
-
**PyTestLog2DB** is a command-line tool that enables you to import pytest_ XML
|
|
25
|
-
result files into TestResultWebApp_'s database for presenting an overview about
|
|
24
|
+
**PyTestLog2DB** is a command-line tool that enables you to import pytest_ XML
|
|
25
|
+
result files into TestResultWebApp_'s database for presenting an overview about
|
|
26
26
|
the whole test execution and detail of each test result.
|
|
27
27
|
|
|
28
|
-
**PyTestLog2DB** tool is operating system independent and only works with
|
|
28
|
+
**PyTestLog2DB** tool is operating system independent and only works with
|
|
29
29
|
Python 3.
|
|
30
30
|
|
|
31
31
|
How to install
|
|
@@ -85,18 +85,18 @@ How to install
|
|
|
85
85
|
|
|
86
86
|
python setup.py install
|
|
87
87
|
|
|
88
|
-
After succesful installation, the executable file **PyTestLog2DB** will be
|
|
89
|
-
available (under *Scripts* folder of Python on Windows and *~/.local/bin/*
|
|
88
|
+
After succesful installation, the executable file **PyTestLog2DB** will be
|
|
89
|
+
available (under *Scripts* folder of Python on Windows and *~/.local/bin/*
|
|
90
90
|
folder on Linux).
|
|
91
91
|
|
|
92
|
-
In case above location is added to **PATH** environment variable then you can
|
|
92
|
+
In case above location is added to **PATH** environment variable then you can
|
|
93
93
|
run it directly as operation system's command.
|
|
94
94
|
|
|
95
95
|
Usage
|
|
96
96
|
-----
|
|
97
97
|
|
|
98
98
|
**PyTestLog2DB** requires the pytest_ result file(s) which contains the test
|
|
99
|
-
result in *JUnit XML* format and TestResultWebApp_'s database information for
|
|
99
|
+
result in *JUnit XML* format and TestResultWebApp_'s database information for
|
|
100
100
|
importing.
|
|
101
101
|
|
|
102
102
|
Use below command to get tools's usage
|
|
@@ -110,7 +110,7 @@ The usage should be showed as below:
|
|
|
110
110
|
|
|
111
111
|
::
|
|
112
112
|
|
|
113
|
-
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
113
|
+
usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
|
|
114
114
|
resultxmlfile server user password database
|
|
115
115
|
|
|
116
116
|
PyTestLog2DB imports pytest JUnit XML report file(s)generated by pytest into a WebApp database.
|
|
@@ -132,9 +132,11 @@ The usage should be showed as below:
|
|
|
132
132
|
--variant VARIANT variant name to be set for this import.
|
|
133
133
|
--versions VERSIONS metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).
|
|
134
134
|
--config CONFIG configuration json file for component mapping information.
|
|
135
|
+
--interface {db,rest}
|
|
136
|
+
database access interface.
|
|
135
137
|
|
|
136
138
|
|
|
137
|
-
The below command is simple usage with all required arguments to import
|
|
139
|
+
The below command is simple usage with all required arguments to import
|
|
138
140
|
pytest_ results into TestResultWebApp's database:
|
|
139
141
|
|
|
140
142
|
::
|
|
@@ -150,13 +152,13 @@ Besides the executable file, you can also run tool as a Python module
|
|
|
150
152
|
Example
|
|
151
153
|
-------
|
|
152
154
|
|
|
153
|
-
In order the import the robot result(s) to TestResultWebApp's database,
|
|
155
|
+
In order the import the robot result(s) to TestResultWebApp's database,
|
|
154
156
|
we need the pytest_ result file in *JUnit XML* format.
|
|
155
157
|
|
|
156
|
-
So, firstly execute the pytest_ testcase(s) to get the result file(s). But the
|
|
158
|
+
So, firstly execute the pytest_ testcase(s) to get the result file(s). But the
|
|
157
159
|
***.xml** result file is not generated by default.
|
|
158
160
|
|
|
159
|
-
We need to specify the argument *--junit-xml=<path>* when executing pytest_
|
|
161
|
+
We need to specify the argument *--junit-xml=<path>* when executing pytest_
|
|
160
162
|
to get the generated *JUnit XML* report file at given path.
|
|
161
163
|
|
|
162
164
|
E.g:
|
|
@@ -171,7 +173,7 @@ and can be used for importing to TestResultWebApp_ with command:
|
|
|
171
173
|
|
|
172
174
|
PyTestLog2DB path/to/result.xml localhost test_user test_pw test_db
|
|
173
175
|
|
|
174
|
-
Then, open TestResultWebApp with your favourite browser and you will see how
|
|
176
|
+
Then, open TestResultWebApp with your favourite browser and you will see how
|
|
175
177
|
wonderful the execution result is displayed as below figures:
|
|
176
178
|
|
|
177
179
|
Dashboard view:
|
|
@@ -187,9 +189,9 @@ Datatable view:
|
|
|
187
189
|
Notes:
|
|
188
190
|
~~~~~~
|
|
189
191
|
|
|
190
|
-
The ***.xml** report file generated by pytest contains only the testcase
|
|
191
|
-
result(s) and less metadata information about the test execution such as
|
|
192
|
-
*project/variant*, *software version*, *tester* , *component*, ...
|
|
192
|
+
The ***.xml** report file generated by pytest contains only the testcase
|
|
193
|
+
result(s) and less metadata information about the test execution such as
|
|
194
|
+
*project/variant*, *software version*, *tester* , *component*, ...
|
|
193
195
|
which are required by TestResultWebApp_.
|
|
194
196
|
|
|
195
197
|
So that, **PyTestLog2DB** will handle those information with the default values.
|
|
@@ -220,13 +222,13 @@ Notes:
|
|
|
220
222
|
|
|
221
223
|
Contribution
|
|
222
224
|
------------
|
|
223
|
-
We are always searching support and you are cordially invited to help to improve
|
|
225
|
+
We are always searching support and you are cordially invited to help to improve
|
|
224
226
|
**PyTestLog2DB** tool.
|
|
225
227
|
|
|
226
228
|
Sourcecode Documentation
|
|
227
229
|
------------------------
|
|
228
230
|
To understand more detail about the tool's features, parameters and how pytest
|
|
229
|
-
result(s) will be displayed on TestResultWebApp, please refer to
|
|
231
|
+
result(s) will be displayed on TestResultWebApp, please refer to
|
|
230
232
|
`PyTestLog2DB tool’s Documentation`_.
|
|
231
233
|
|
|
232
234
|
Feedback
|
|
@@ -260,7 +262,7 @@ Contributors
|
|
|
260
262
|
License
|
|
261
263
|
~~~~~~~
|
|
262
264
|
|
|
263
|
-
Copyright 2020-
|
|
265
|
+
Copyright 2020-2023 Robert Bosch GmbH
|
|
264
266
|
|
|
265
267
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
266
268
|
you may not use this file except in compliance with the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# **************************************************************************************************************
|
|
2
2
|
#
|
|
3
|
-
# Copyright 2020-
|
|
3
|
+
# Copyright 2020-2023 Robert Bosch GmbH
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|