PyTestLog2DB 0.3.1__tar.gz → 0.4.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.
@@ -0,0 +1 @@
1
+ include build_backend.py
@@ -0,0 +1,346 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyTestLog2DB
3
+ Version: 0.4.0
4
+ Summary: Imports pytest result(s) to TestResultWebApp database
5
+ Author-email: Tran Duy Ngoan <Ngoan.TranDuy@vn.bosch.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://pypi.org/project/PyTestLog2DB/
8
+ Project-URL: Documentation, https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/PyTestLog2DB/PyTestLog2DB.pdf
9
+ Project-URL: Readme, https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/README.rst
10
+ Project-URL: Repository, https://github.com/test-fullautomation/python-pytestlog2db
11
+ Project-URL: Issues, https://github.com/test-fullautomation/python-pytestlog2db/issues
12
+ Keywords: pytest,testresults,database
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/x-rst
18
+ License-File: LICENSE
19
+ Requires-Dist: docutils>=0.22.4
20
+ Requires-Dist: colorama
21
+ Requires-Dist: TestResultDBAccess
22
+ Requires-Dist: lxml
23
+ Requires-Dist: PythonExtensionsCollection
24
+ Requires-Dist: GenPackageDoc
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=6.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=3.0; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: docutils>=0.22.4; extra == "docs"
30
+ Dynamic: license-file
31
+
32
+ PyTestLog2DB
33
+ ============
34
+
35
+ Table of Contents
36
+ -----------------
37
+
38
+ - `Getting Started <#getting-started>`__
39
+
40
+ - `How to install <#how-to-install>`__
41
+ - `Usage <#usage>`__
42
+ - `Example <#example>`__
43
+ - `Contribution <#contribution>`__
44
+ - `Sourcecode Documentation <#sourcecode-documentation>`__
45
+ - `Feedback <#feedback>`__
46
+ - `About <#about>`__
47
+
48
+ - `Maintainers <#maintainers>`__
49
+ - `Contributors <#contributors>`__
50
+ - `License <#license>`__
51
+
52
+ Getting Started
53
+ ---------------
54
+
55
+ **PyTestLog2DB** is a command-line tool that enables you to import pytest_ XML
56
+ result files into TestResultWebApp_'s database for presenting an overview about
57
+ the whole test execution and detail of each test result.
58
+
59
+ **PyTestLog2DB** tool is operating system independent and only works with
60
+ Python 3.
61
+
62
+ How to install
63
+ ~~~~~~~~~~~~~~
64
+
65
+ **PyTestLog2DB** can be installed in two different ways.
66
+
67
+ The **PyTestLog2DB** can be installed in two different ways.
68
+
69
+ 1. Installation via PyPi (recommended for users)
70
+
71
+ .. code::
72
+
73
+ pip install PyTestLog2DB
74
+
75
+ `PyTestLog2DB in PyPi <https://pypi.org/project/PyTestLog2DB/>`_
76
+
77
+ 2. Installation via GitHub (recommended for developers)
78
+
79
+ * Clone the **python-pytestlog2db** repository to your machine.
80
+
81
+ .. code::
82
+
83
+ git clone https://github.com/test-fullautomation/python-pytestlog2db.git
84
+
85
+ `PyTestLog2DB in GitHub <https://github.com/test-fullautomation/python-PyTestLog2DB>`_
86
+
87
+ * Use the following command to install **PyTestLog2DB** (executed in repository main folder):
88
+
89
+ .. code::
90
+
91
+ python -m pip install .
92
+
93
+ Or:
94
+
95
+ .. code::
96
+
97
+ python -m pip install --proxy <proxy> .
98
+
99
+ This command will also download and install all dependencies that are required to work with the source files in the current repository.
100
+ After the initial installation of **PyTestLog2DB** is done, you have the following two possibilities:
101
+
102
+ 1. *Clean the previous installation*:
103
+
104
+ .. code::
105
+
106
+ python "./cleanup_installation.py"
107
+
108
+ ``cleanup_installation.py`` explicitly deletes all files and folders within the component installation folder under
109
+ ``site-packages`` and also deletes local build artefacts.
110
+
111
+ 2. *Render the component documentation*:
112
+
113
+ .. code::
114
+
115
+ python "./genpackagedoc.py"
116
+
117
+ This would e.g. be required in case of changes in the interface of **PyTestLog2DB**.
118
+
119
+ The documentation is rendered by a separate application called **GenPackageDoc**, that is part
120
+ of the build dependencies and runtime dependencies of **PyTestLog2DB**.
121
+
122
+ **GenPackageDoc** needs to be configured. Details about how to do this, can be found in the
123
+ `README.rst <https://github.com/test-fullautomation/python-genpackagedoc/blob/develop/README.rst>`_
124
+ (sections *Install dependencies* and *Configure dependencies*).
125
+
126
+ * Use the following command to build **PyTestLog2DB** (executed in repository main folder):
127
+
128
+ .. code::
129
+
130
+ python -m build .
131
+
132
+ Or:
133
+
134
+ .. code::
135
+
136
+ python -m pip config set global.proxy <proxy>
137
+ python -m build .
138
+
139
+ After succesful installation, the executable file **PyTestLog2DB** will be
140
+ available (under *Scripts* folder of Python on Windows and *~/.local/bin/*
141
+ folder on Linux).
142
+
143
+ In case above location is added to **PATH** environment variable then you can
144
+ run it directly as operation system's command.
145
+
146
+ Usage
147
+ -----
148
+
149
+ **PyTestLog2DB** requires the pytest_ result file(s) which contains the test
150
+ result in *JUnit XML* format and TestResultWebApp_'s database information for
151
+ importing.
152
+
153
+ Use below command to get tools's usage
154
+
155
+ ::
156
+
157
+ PyTestLog2DB -h
158
+
159
+
160
+ The usage should be showed as below:
161
+
162
+ ::
163
+
164
+ usage: PyTestLog2DB (PyTestXMLReport to TestResultWebApp importer) [-h] [-v] [--recursive] [--dryrun] [--append] [--UUID UUID] [--variant VARIANT] [--versions VERSIONS] [--config CONFIG]
165
+ resultxmlfile server user password database
166
+
167
+ PyTestLog2DB imports pytest JUnit XML report file(s)generated by pytest into a WebApp database.
168
+
169
+ positional arguments:
170
+ resultxmlfile absolute or relative path to the pytest JUnit XML report file or directory of report files to be imported.
171
+ server server which hosts the database (IP or URL).
172
+ user user for database login.
173
+ password password for database login.
174
+ database database schema for database login.
175
+
176
+ optional arguments:
177
+ -h, --help show this help message and exit
178
+ -v, --version version of the PyTestLog2DB importer.
179
+ --recursive if set, then the path is searched recursively for output files to be imported.
180
+ --dryrun if set, then verify all input arguments (includes DB connection) and show what would be done.
181
+ --append is used in combination with --UUID <UUID>. If set, allow to append new result(s) to existing execution result UUID in --UUID argument.
182
+ --UUID UUID UUID used to identify the import and version ID on webapp. If not provided PyTestLog2DB will generate an UUID for the whole import.
183
+ --variant VARIANT variant name to be set for this import.
184
+ --versions VERSIONS metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).
185
+ --config CONFIG configuration json file for component mapping information.
186
+ --interface {db,rest}
187
+ database access interface.
188
+ --testrunurl TESTRUNURL
189
+ link to test execution job: Jenkins job, Gitlab CI/CD pipeline, ...
190
+
191
+ The below command is simple usage with all required arguments to import
192
+ pytest_ results into TestResultWebApp's database:
193
+
194
+ ::
195
+
196
+ PyTestLog2DB <resultxmlfile> <server> <user> <password> <database>
197
+
198
+ Besides the executable file, you can also run tool as a Python module
199
+
200
+ ::
201
+
202
+ python -m PyTestLog2DB <resultxmlfile> <server> <user> <password> <database>
203
+
204
+ Example
205
+ -------
206
+
207
+ In order the import the robot result(s) to TestResultWebApp's database,
208
+ we need the pytest_ result file in *JUnit XML* format.
209
+
210
+ So, firstly execute the pytest_ testcase(s) to get the result file(s). But the
211
+ ***.xml** result file is not generated by default.
212
+
213
+ We need to specify the argument *--junit-xml=<path>* when executing pytest_
214
+ to get the generated *JUnit XML* report file at given path.
215
+
216
+ E.g:
217
+ ::
218
+
219
+ pytest --junit-xml=path/to/result.xml pytest/folder
220
+
221
+ After that, the ***.xml** result file will be available at **path/to/result.xml**
222
+ and can be used for importing to TestResultWebApp_ with command:
223
+
224
+ ::
225
+
226
+ PyTestLog2DB path/to/result.xml localhost test_user test_pw test_db
227
+
228
+ Then, open TestResultWebApp with your favourite browser and you will see how
229
+ wonderful the execution result is displayed as below figures:
230
+
231
+ Dashboard view:
232
+
233
+ .. image:: https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/packagedoc/additional_docs/pictures/Dashboard.png?raw=true
234
+ :alt: Dashboard view
235
+
236
+ Datatable view:
237
+
238
+ .. image:: https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/packagedoc/additional_docs/pictures/Datatable.png?raw=true
239
+ :alt: Datatable view
240
+
241
+ Notes:
242
+ ~~~~~~
243
+
244
+ The ***.xml** report file generated by pytest contains only the testcase
245
+ result(s) and less metadata information about the test execution such as
246
+ *project/variant*, *software version*, *tester* , *component*, ...
247
+ which are required by TestResultWebApp_.
248
+
249
+ So that, **PyTestLog2DB** will handle those information with the default values.
250
+
251
+ But you can use the optional argument *--config CONFIG* to specify those
252
+ information when importing to TestResultWebApp_'s database.
253
+
254
+ Sample configuration file:
255
+
256
+ ::
257
+
258
+ {
259
+ "variant" : "MyProject",
260
+ "version_sw": "0.1.1",
261
+ "components": {
262
+ "Testsuite1" : "test-data.test_tsclass.TestSuite1",
263
+ "Testsuite2" : "test-data.test_tsclass.TestSuite2",
264
+ "Others" : [
265
+ "test-data.test_ts1",
266
+ "test-data.test_ts2"
267
+ ]
268
+ },
269
+ "tester" : "Tran Duy Ngoan"
270
+ }
271
+
272
+ Please refer `PyTestLog2DB tool’s Documentation`_ for more detail about default
273
+ values and the configuration json file.
274
+
275
+ Contribution
276
+ ------------
277
+ We are always searching support and you are cordially invited to help to improve
278
+ **PyTestLog2DB** tool.
279
+
280
+ Sourcecode Documentation
281
+ ------------------------
282
+ To understand more detail about the tool's features, parameters and how pytest
283
+ result(s) will be displayed on TestResultWebApp, please refer to
284
+ `PyTestLog2DB tool’s Documentation`_.
285
+
286
+ Feedback
287
+ --------
288
+ Please feel free to give any feedback to us via
289
+
290
+ Email to: `Thomas Pollerspöck`_
291
+
292
+ Issue tracking: `PyTestLog2DB Issues`_
293
+
294
+ About
295
+ -----
296
+
297
+ Maintainers
298
+ ~~~~~~~~~~~
299
+ `Thomas Pollerspöck`_
300
+
301
+ `Holger Queckenstedt`_
302
+
303
+ `Tran Duy Ngoan`_
304
+
305
+ Contributors
306
+ ~~~~~~~~~~~~
307
+
308
+ `Nguyen Huynh Tri Cuong`_
309
+
310
+ `Mai Dinh Nam Son`_
311
+
312
+ `Tran Hoang Nguyen`_
313
+
314
+ License
315
+ ~~~~~~~
316
+
317
+ Copyright 2020-2023 Robert Bosch GmbH
318
+
319
+ Licensed under the Apache License, Version 2.0 (the "License");
320
+ you may not use this file except in compliance with the License.
321
+ You may obtain a copy of the License at
322
+
323
+ |License: Apache v2|
324
+
325
+ Unless required by applicable law or agreed to in writing, software
326
+ distributed under the License is distributed on an "AS IS" BASIS,
327
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
328
+ See the License for the specific language governing permissions and
329
+ limitations under the License.
330
+
331
+
332
+ .. |License: Apache v2| image:: https://img.shields.io/pypi/l/robotframework.svg
333
+ :target: http://www.apache.org/licenses/LICENSE-2.0.html
334
+ .. _pytest: https://docs.pytest.org
335
+ .. _JUnit XML: https://llg.cubic.org/docs/junit
336
+ .. _PyTestLog2DB: https://github.com/test-fullautomation/python-pytestlog2db
337
+ .. _TestResultWebApp: https://github.com/test-fullautomation/TestResultWebApp
338
+ .. _PyPI: https://pypi.org/
339
+ .. _Thomas Pollerspöck: mailto:Thomas.Pollerspoeck@de.bosch.com
340
+ .. _Tran Duy Ngoan: mailto:Ngoan.TranDuy@vn.bosch.com
341
+ .. _Nguyen Huynh Tri Cuong: mailto:Cuong.NguyenHuynhTri@vn.bosch.com
342
+ .. _Mai Dinh Nam Son: mailto:Son.MaiDinhNam@vn.bosch.com
343
+ .. _Tran Hoang Nguyen: mailto:Nguyen.TranHoang@vn.bosch.com
344
+ .. _Holger Queckenstedt: mailto:Holger.Queckenstedt@de.bosch.com
345
+ .. _PyTestLog2DB tool’s Documentation: https://github.com/test-fullautomation/python-pytestlog2db/blob/develop/PyTestLog2DB/PyTestLog2DB.pdf
346
+ .. _PyTestLog2DB Issues: https://github.com/test-fullautomation/python-pytestlog2db/issues
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2023 Robert Bosch GmbH
1
+ # Copyright 2020-2026 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2023 Robert Bosch GmbH
1
+ # Copyright 2020-2026 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2023 Robert Bosch GmbH
1
+ # Copyright 2020-2026 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.
@@ -37,13 +37,13 @@ import colorama as col
37
37
  import json
38
38
  from lxml import etree
39
39
  from datetime import datetime, timedelta
40
+ from dateutil import parser
40
41
  import platform
41
42
  from pkg_resources import get_distribution
42
43
 
43
44
  from TestResultDBAccess import DBAccessFactory
44
45
  from PyTestLog2DB.version import VERSION, VERSION_DATE
45
46
 
46
- PYTEST_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
47
47
  DB_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
48
48
 
49
49
  def __current_user():
@@ -305,6 +305,7 @@ Avalable arguments in command line:
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
307
  - `--interface` : database access interface.
308
+ - `--testrunurl`: link to test execution job: Jenkins job, Gitlab CI/CD pipeline, ...
308
309
 
309
310
  **Arguments:**
310
311
 
@@ -337,6 +338,7 @@ Avalable arguments in command line:
337
338
  cmdlineparser.add_argument('--versions', type=str, help='metadata: Versions (Software;Hardware;Test) to be set for this import (semicolon separated).')
338
339
  cmdlineparser.add_argument('--config', type=str, help='configuration json file for component mapping information.')
339
340
  cmdlineparser.add_argument('--interface', choices=['db', 'rest'], default='db', help='database access interface.')
341
+ cmdlineparser.add_argument('--testrunurl', type=str, default="", help='link to test execution job: Jenkins job, Gitlab CI/CD pipeline, ...')
340
342
 
341
343
  return cmdlineparser.parse_args()
342
344
 
@@ -583,13 +585,13 @@ Besides, `starttime` and `endtime` are also calculated and added in the merged r
583
585
  if oMergedTree == None:
584
586
  oMergedTree = oTree
585
587
  sStartTime = oMergedTree.getchildren()[0].get("timestamp")
586
- dtStartTime = datetime.strptime(sStartTime, PYTEST_DATETIME_FORMAT)
588
+ dtStartTime = parser.parse(sStartTime)
587
589
  dtEndTime = dtStartTime + timedelta(seconds=float(oMergedTree.getchildren()[0].get("time")))
588
590
  else:
589
591
  oAdditionalTree = etree.parse(item)
590
592
  for oSuite in oAdditionalTree.getroot().iterchildren("testsuite"):
591
593
  oMergedTree.append(oSuite)
592
- dtTimestamp = datetime.strptime(oSuite.get("timestamp"), PYTEST_DATETIME_FORMAT)
594
+ dtTimestamp = parser.parse(oSuite.get("timestamp"))
593
595
 
594
596
  # check starttime and endtime for the execution result
595
597
  if dtTimestamp < dtStartTime:
@@ -939,8 +941,8 @@ Process to the lowest suite level (test file):
939
941
  _tbl_file_id = None
940
942
  _tbl_file_tester_account = dConfig["tester"]
941
943
  _tbl_file_tester_machine = suite.get("hostname")
942
- _tbl_file_time_start = suite.get("timestamp")
943
- test_start_time = datetime.strptime(_tbl_file_time_start, PYTEST_DATETIME_FORMAT)
944
+ test_start_time = parser.parse(suite.get("timestamp"))
945
+ _tbl_file_time_start = datetime.strftime(test_start_time, DB_DATETIME_FORMAT)
944
946
  _tbl_file_time_end = datetime.strftime(test_start_time + timedelta(seconds=float(suite.get("time"))), DB_DATETIME_FORMAT)
945
947
 
946
948
  test_number = 1
@@ -1076,6 +1078,7 @@ Flow to import PyTest results to database:
1076
1078
  * `variant` : variant name to be set for this import.
1077
1079
  * `versions` : metadata: Versions (Software;Hardware;Test) to be set for this import.
1078
1080
  * `config` : configuration json file for component mapping information.
1081
+ * `testrunurl`: link to test execution job: Jenkins job, Gitlab CI/CD pipeline, ...
1079
1082
 
1080
1083
  **Returns:**
1081
1084
 
@@ -1176,7 +1179,7 @@ Flow to import PyTest results to database:
1176
1179
  # Set version as start time of the execution if not provided in metadata
1177
1180
  # Format: %Y%m%d_%H%M%S from %Y-%m-%d %H:%M:%S
1178
1181
  if _tbl_result_version_sw_target=="":
1179
- _tbl_result_version_sw_target = datetime.strftime(datetime.strptime(pytest_result.get("starttime"), DB_DATETIME_FORMAT), "%Y%m%d_%H%M%S")
1182
+ _tbl_result_version_sw_target = datetime.strftime(parser.parse(pytest_result.get("starttime")), "%Y%m%d_%H%M%S")
1180
1183
 
1181
1184
  if not args.append:
1182
1185
  Logger.log(f"Set project/variant to '{sVariant}' ({sMsgVarirantSetBy})")
@@ -1199,7 +1202,7 @@ Flow to import PyTest results to database:
1199
1202
 
1200
1203
  # Process other info
1201
1204
  _tbl_result_interpretation = ""
1202
- _tbl_result_jenkinsurl = ""
1205
+ _tbl_result_jenkinsurl = args.testrunurl
1203
1206
  _tbl_result_reporting_qualitygate = ""
1204
1207
 
1205
1208
  # Check the UUID is existing or not
@@ -1,6 +1,6 @@
1
1
  # **************************************************************************************************************
2
2
  #
3
- # Copyright 2020-2023 Robert Bosch GmbH
3
+ # Copyright 2020-2026 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,5 @@
18
18
  #
19
19
  # Version and date of PyTestLog2DB
20
20
  #
21
- VERSION = "0.3.1"
22
- VERSION_DATE = "20.05.2024"
23
-
21
+ VERSION = "0.4.0"
22
+ VERSION_DATE = "23.03.2026"