qase-python-commons 3.2.7__tar.gz → 3.3.1__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.

Potentially problematic release.


This version of qase-python-commons might be problematic. Click here for more details.

Files changed (44) hide show
  1. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/PKG-INFO +1 -1
  2. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/pyproject.toml +1 -1
  3. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/client/api_v1_client.py +5 -3
  4. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/client/api_v2_client.py +5 -3
  5. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/__init__.py +3 -2
  6. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/result.py +86 -0
  7. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/reporters/core.py +17 -5
  8. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/reporters/report.py +3 -3
  9. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/reporters/testops.py +2 -2
  10. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase_python_commons.egg-info/PKG-INFO +1 -1
  11. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/README.md +0 -0
  12. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/setup.cfg +0 -0
  13. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/__init__.py +0 -0
  14. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/client/base_api_client.py +0 -0
  15. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/config.py +0 -0
  16. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/exceptions/reporter.py +0 -0
  17. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/loader.py +0 -0
  18. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/logger.py +0 -0
  19. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/attachment.py +0 -0
  20. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/basemodel.py +0 -0
  21. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/api.py +0 -0
  22. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/batch.py +0 -0
  23. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/connection.py +0 -0
  24. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/framework.py +0 -0
  25. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/plan.py +0 -0
  26. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/qaseconfig.py +0 -0
  27. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/report.py +0 -0
  28. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/run.py +0 -0
  29. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/config/testops.py +0 -0
  30. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/relation.py +0 -0
  31. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/run.py +0 -0
  32. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/runtime.py +0 -0
  33. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/models/step.py +0 -0
  34. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/profilers/__init__.py +0 -0
  35. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/profilers/db.py +0 -0
  36. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/profilers/network.py +0 -0
  37. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/profilers/sleep.py +0 -0
  38. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/reporters/__init__.py +0 -0
  39. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/utils.py +0 -0
  40. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase/commons/validators/base.py +0 -0
  41. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase_python_commons.egg-info/SOURCES.txt +0 -0
  42. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase_python_commons.egg-info/dependency_links.txt +0 -0
  43. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase_python_commons.egg-info/requires.txt +0 -0
  44. {qase_python_commons-3.2.7 → qase_python_commons-3.3.1}/src/qase_python_commons.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: qase-python-commons
3
- Version: 3.2.7
3
+ Version: 3.3.1
4
4
  Summary: A library for Qase TestOps and Qase Report
5
5
  Author-email: Qase Team <support@qase.io>
6
6
  Project-URL: Homepage, https://github.com/qase-tms/qase-python/tree/main/qase-python-commons
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qase-python-commons"
7
- version = "3.2.7"
7
+ version = "3.3.1"
8
8
  description = "A library for Qase TestOps and Qase Report"
9
9
  readme = "README.md"
10
10
  authors = [{name = "Qase Team", email = "support@qase.io"}]
@@ -1,3 +1,4 @@
1
+ from datetime import datetime, timezone
1
2
  from typing import Dict, Union
2
3
 
3
4
  import certifi
@@ -7,7 +8,7 @@ from qase.api_client_v1.configuration import Configuration
7
8
  from .. import Logger
8
9
  from .base_api_client import BaseApiClient
9
10
  from ..exceptions.reporter import ReporterException
10
- from ..models import Attachment, Result, Step
11
+ from ..models import Attachment, InternalResult, Step
11
12
  from ..models.config.framework import Video, Trace
12
13
  from ..models.config.qaseconfig import QaseConfig
13
14
  from ..models.step import StepType
@@ -99,7 +100,8 @@ class ApiV1Client(BaseApiClient):
99
100
  description=description,
100
101
  environment_id=(int(environment_id) if environment_id else None),
101
102
  plan_id=(int(plan_id) if plan_id else plan_id),
102
- is_autotest=True
103
+ is_autotest=True,
104
+ start_time=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
103
105
  )
104
106
  self.logger.log_debug(f"Creating test run with parameters: {kwargs}")
105
107
  try:
@@ -134,7 +136,7 @@ class ApiV1Client(BaseApiClient):
134
136
  )
135
137
  self.logger.log_debug(f"Results for run {run_id} sent successfully")
136
138
 
137
- def _prepare_result(self, project_code: str, result: Result) -> Dict:
139
+ def _prepare_result(self, project_code: str, result: InternalResult) -> Dict:
138
140
  attached = []
139
141
  if result.attachments:
140
142
  for attachment in result.attachments:
@@ -17,7 +17,7 @@ from .api_v1_client import ApiV1Client
17
17
  from .. import Logger
18
18
  from ..exceptions.reporter import ReporterException
19
19
  from ..models.config.framework import Video, Trace
20
- from ..models import Attachment, Result
20
+ from ..models import Attachment, InternalResult
21
21
  from ..models.config.qaseconfig import QaseConfig
22
22
  from ..models.step import StepType, Step
23
23
 
@@ -53,7 +53,7 @@ class ApiV2Client(ApiV1Client):
53
53
  create_results_request_v2=CreateResultsRequestV2(results=results_to_send))
54
54
  self.logger.log_debug(f"Results for run {run_id} sent successfully")
55
55
 
56
- def _prepare_result(self, project_code: str, result: Result) -> ResultCreate:
56
+ def _prepare_result(self, project_code: str, result: InternalResult) -> ResultCreate:
57
57
  attached = []
58
58
  if result.attachments:
59
59
  for attachment in result.attachments:
@@ -78,6 +78,7 @@ class ApiV2Client(ApiV1Client):
78
78
  signature=result.signature,
79
79
  testops_id=result.get_testops_id(),
80
80
  execution=ResultExecution(status=result.execution.status, duration=result.execution.duration,
81
+ start_time=result.execution.start_time, end_time=result.execution.end_time,
81
82
  stacktrace=result.execution.stacktrace, thread=result.execution.thread),
82
83
  fields=ResultCreateFields.from_dict(result.fields),
83
84
  attachments=[attach.hash for attach in attached],
@@ -85,7 +86,6 @@ class ApiV2Client(ApiV1Client):
85
86
  steps_type=ResultStepsType.CLASSIC,
86
87
  params=result.params,
87
88
  param_groups=result.param_groups,
88
- muted=False,
89
89
  message=result.message,
90
90
  defect=self.config.testops.defect,
91
91
  )
@@ -113,6 +113,8 @@ class ApiV2Client(ApiV1Client):
113
113
  prepared_step = {'execution': {}, 'data': {}, 'steps': []}
114
114
  prepared_step['execution']['status'] = ResultStepStatus(step.execution.status)
115
115
  prepared_step['execution']['duration'] = step.execution.duration
116
+ prepared_step['execution']['start_time'] = step.execution.start_time
117
+ prepared_step['execution']['end_time'] = step.execution.end_time
116
118
 
117
119
  if step.step_type == StepType.TEXT:
118
120
  prepared_step['data']['action'] = step.data.action
@@ -1,4 +1,4 @@
1
- from .result import Result, Field
1
+ from .result import Result, InternalResult, Field
2
2
  from .run import Run
3
3
  from .attachment import Attachment
4
4
  from .relation import Relation
@@ -12,5 +12,6 @@ __all__ = [
12
12
  Relation,
13
13
  Step,
14
14
  Runtime,
15
- Field
15
+ Field,
16
+ InternalResult
16
17
  ]
@@ -1,3 +1,4 @@
1
+ import copy
1
2
  import time
2
3
  import uuid
3
4
 
@@ -65,6 +66,70 @@ class Request(BaseModel):
65
66
 
66
67
 
67
68
  class Result(BaseModel):
69
+ def __init__(self, title: str, signature: str) -> None:
70
+ self.id: str = str(uuid.uuid4())
71
+ self.title: str = title
72
+ self.signature: str = signature
73
+ self.run_id: Optional[str] = None
74
+ self.testops_id: Optional[List[int]] = None
75
+ self.execution: Type[Execution] = Execution()
76
+ self.fields: Dict[Type[Field]] = {}
77
+ self.attachments: List[Attachment] = []
78
+ self.steps: List[Type[Step]] = []
79
+ self.params: Optional[dict] = {}
80
+ self.param_groups: Optional[List[List[str]]] = []
81
+ self.author: Optional[str] = None
82
+ self.relations: Type[Relation] = None
83
+ self.muted: bool = False
84
+ self.message: Optional[str] = None
85
+ QaseUtils.get_host_data()
86
+
87
+ def add_message(self, message: str) -> None:
88
+ self.message = message
89
+
90
+ def add_field(self, field: Type[Field]) -> None:
91
+ self.fields[field.name] = field.value
92
+
93
+ def add_steps(self, steps: List[Type[Step]]) -> None:
94
+ self.steps = QaseUtils().build_tree(steps)
95
+
96
+ def add_attachment(self, attachment: Attachment) -> None:
97
+ self.attachments.append(attachment)
98
+
99
+ def add_param(self, key: str, value: str) -> None:
100
+ self.params[key] = value
101
+
102
+ def add_param_groups(self, values: List[str]) -> None:
103
+ self.param_groups.append(values)
104
+
105
+ def set_relation(self, relation: Relation) -> None:
106
+ self.relations = relation
107
+
108
+ def get_status(self) -> Optional[str]:
109
+ return self.execution.status
110
+
111
+ def get_id(self) -> str:
112
+ return self.id
113
+
114
+ def get_title(self) -> str:
115
+ return self.title
116
+
117
+ def get_field(self, name: str) -> Optional[Type[Field]]:
118
+ if name in self.fields:
119
+ return self.fields[name]
120
+ return None
121
+
122
+ def get_testops_id(self) -> Optional[List[int]]:
123
+ return self.testops_id
124
+
125
+ def get_duration(self) -> int:
126
+ return self.execution.duration
127
+
128
+ def set_run_id(self, run_id: str) -> None:
129
+ self.run_id = run_id
130
+
131
+
132
+ class InternalResult(BaseModel):
68
133
  def __init__(self, title: str, signature: str) -> None:
69
134
  self.id: str = str(uuid.uuid4())
70
135
  self.title: str = title
@@ -126,3 +191,24 @@ class Result(BaseModel):
126
191
 
127
192
  def set_run_id(self, run_id: str) -> None:
128
193
  self.run_id = run_id
194
+
195
+ @classmethod
196
+ def convert_from_result(cls, result: Result, testops_id: Optional[int] = None):
197
+ int_result = cls(result.title, result.signature)
198
+
199
+ int_result.id = result.id
200
+ int_result.title = result.title
201
+ int_result.signature = result.signature
202
+ int_result.run_id = result.run_id
203
+ int_result.testops_id = testops_id
204
+ int_result.execution = copy.deepcopy(result.execution)
205
+ int_result.fields = result.fields
206
+ int_result.attachments = result.attachments
207
+ int_result.steps = result.steps
208
+ int_result.params = result.params
209
+ int_result.author = result.author
210
+ int_result.relations = result.relations
211
+ int_result.muted = result.muted
212
+ int_result.message = result.message
213
+
214
+ return int_result
@@ -1,5 +1,3 @@
1
- import os
2
- import json
3
1
  import time
4
2
 
5
3
  from ..config import ConfigManager
@@ -8,7 +6,7 @@ from ..logger import Logger
8
6
  from .report import QaseReport
9
7
  from .testops import QaseTestOps
10
8
 
11
- from ..models import Result, Attachment, Runtime
9
+ from ..models import InternalResult, Result, Attachment, Runtime
12
10
  from ..models.config.qaseconfig import Mode
13
11
  from typing import Union, List
14
12
 
@@ -81,7 +79,21 @@ class QaseCoreReporter:
81
79
  try:
82
80
  ts = time.time()
83
81
  self.logger.log_debug(f"Adding result {result}")
84
- self.reporter.add_result(result)
82
+ ids = result.get_testops_id()
83
+
84
+ if ids is None:
85
+ int_result = InternalResult.convert_from_result(result)
86
+ self.reporter.add_result(int_result)
87
+ else:
88
+ first = True
89
+ for testops_id in ids:
90
+ int_result = InternalResult.convert_from_result(result, testops_id)
91
+ if not first:
92
+ int_result.execution.duration = 0
93
+ else:
94
+ first = False
95
+ self.reporter.add_result(int_result)
96
+
85
97
  self.logger.log_debug(f"Result {result.get_title()} added")
86
98
  self.overhead += time.time() - ts
87
99
  except Exception as e:
@@ -180,7 +192,7 @@ class QaseCoreReporter:
180
192
  host=self.config.testops.api.host
181
193
  )
182
194
  self._execution_plan = loader.load(self.config.testops.project,
183
- int(self.config.testops.plan.id))
195
+ int(self.config.testops.plan.id))
184
196
  except Exception as e:
185
197
  self.logger.log('Failed to load test plan from Qase TestOps', 'info')
186
198
  self.logger.log(e, 'error')
@@ -3,7 +3,7 @@ import os
3
3
  import shutil
4
4
  import json
5
5
  import re
6
- from ..models import Result, Run, Attachment
6
+ from ..models import InternalResult, Run, Attachment
7
7
  from .. import QaseUtils, Logger
8
8
  from ..models.config.connection import Format
9
9
  from ..models.config.qaseconfig import QaseConfig
@@ -40,7 +40,7 @@ class QaseReport:
40
40
  def complete_worker(self):
41
41
  pass
42
42
 
43
- def add_result(self, result: Result):
43
+ def add_result(self, result: InternalResult):
44
44
  result.set_run_id(self.run_id)
45
45
  for attachment in result.attachments:
46
46
  self._persist_attachment(attachment)
@@ -91,7 +91,7 @@ class QaseReport:
91
91
  self._persist_attachments_in_steps(step.steps)
92
92
 
93
93
  # Method saves result to a file
94
- def _store_result(self, result: Result):
94
+ def _store_result(self, result: InternalResult):
95
95
  self._store_object(result, self.report_path + "/results/", result.id)
96
96
 
97
97
  def _check_report_path(self):
@@ -6,7 +6,7 @@ from typing import List
6
6
  from .. import Logger, ReporterException
7
7
  from ..client.api_v1_client import ApiV1Client
8
8
  from ..client.base_api_client import BaseApiClient
9
- from ..models import Result
9
+ from ..models import InternalResult
10
10
  from ..models.config.qaseconfig import QaseConfig
11
11
 
12
12
  DEFAULT_BATCH_SIZE = 200
@@ -129,7 +129,7 @@ class QaseTestOps:
129
129
  if len(self.results) > 0:
130
130
  self._send_results()
131
131
 
132
- def add_result(self, result: Result) -> None:
132
+ def add_result(self, result: InternalResult) -> None:
133
133
  if result.get_status() == 'failed':
134
134
  self.__show_link(result.testops_id, result.title)
135
135
  self.results.append(result)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: qase-python-commons
3
- Version: 3.2.7
3
+ Version: 3.3.1
4
4
  Summary: A library for Qase TestOps and Qase Report
5
5
  Author-email: Qase Team <support@qase.io>
6
6
  Project-URL: Homepage, https://github.com/qase-tms/qase-python/tree/main/qase-python-commons