qase-python-commons 3.4.0__py3-none-any.whl → 3.4.2__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.

Potentially problematic release.


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

@@ -125,18 +125,18 @@ class ApiV2Client(ApiV1Client):
125
125
  prepared_step['data']['action'] = step.data.request_method + " " + step.data.request_url
126
126
 
127
127
  if step.data.request_body:
128
- step.attachments.append(
128
+ step.add_attachment(
129
129
  Attachment(file_name='request_body.txt', content=step.data.request_body, mime_type='text/plain',
130
130
  temporary=True))
131
131
  if step.data.request_headers:
132
- step.attachments.append(
132
+ step.add_attachment(
133
133
  Attachment(file_name='request_headers.txt', content=step.data.request_headers,
134
134
  mime_type='text/plain', temporary=True))
135
135
  if step.data.response_body:
136
- step.attachments.append(Attachment(file_name='response_body.txt', content=step.data.response_body,
137
- mime_type='text/plain', temporary=True))
136
+ step.add_attachment(Attachment(file_name='response_body.txt', content=step.data.response_body,
137
+ mime_type='text/plain', temporary=True))
138
138
  if step.data.response_headers:
139
- step.attachments.append(
139
+ step.add_attachment(
140
140
  Attachment(file_name='response_headers.txt', content=step.data.response_headers,
141
141
  mime_type='text/plain', temporary=True))
142
142
 
@@ -149,9 +149,9 @@ class ApiV2Client(ApiV1Client):
149
149
  if step.step_type == StepType.SLEEP:
150
150
  prepared_step['data']['action'] = f"Sleep for {step.data.duration} seconds"
151
151
 
152
- if step.attachments:
152
+ if step.execution.attachments:
153
153
  uploaded_attachments = []
154
- for file in step.attachments:
154
+ for file in step.execution.attachments:
155
155
  attach_id = self._upload_attachment(project_code, file)
156
156
  if attach_id:
157
157
  uploaded_attachments.extend(attach_id)
qase/commons/config.py CHANGED
@@ -53,7 +53,7 @@ class ConfigManager:
53
53
  if config.get("profilers"):
54
54
  self.config.set_profilers(config.get("profilers"))
55
55
 
56
- if config.get("debug"):
56
+ if config.get("debug") is not None:
57
57
  self.config.set_debug(
58
58
  config.get("debug")
59
59
  )
@@ -78,7 +78,7 @@ class ConfigManager:
78
78
  if testops.get("project"):
79
79
  self.config.testops.set_project(testops.get("project"))
80
80
 
81
- if testops.get("defect"):
81
+ if testops.get("defect") is not None:
82
82
  self.config.testops.set_defect(
83
83
  testops.get("defect")
84
84
  )
@@ -101,7 +101,7 @@ class ConfigManager:
101
101
  if run.get("description"):
102
102
  self.config.testops.run.set_description(run.get("description"))
103
103
 
104
- if run.get("complete"):
104
+ if run.get("complete") is not None:
105
105
  self.config.testops.run.set_complete(
106
106
  run.get("complete")
107
107
  )
@@ -135,7 +135,7 @@ class ConfigManager:
135
135
  if framework.get("pytest"):
136
136
  pytest = framework.get("pytest")
137
137
 
138
- if pytest.get("captureLogs"):
138
+ if pytest.get("captureLogs") is not None:
139
139
  self.config.framework.pytest.set_capture_logs(
140
140
  pytest.get("captureLogs")
141
141
  )
qase/commons/logger.py CHANGED
@@ -24,7 +24,12 @@ class Logger:
24
24
  def log(self, message: str, level: str = 'info'):
25
25
  time_str = self._get_timestamp("%H:%M:%S")
26
26
  log = f"[Qase][{time_str}][{level}] {message}\n"
27
- print(log)
27
+
28
+ try:
29
+ print(log, end='')
30
+ except (OSError, IOError):
31
+ pass
32
+
28
33
  if self.debug:
29
34
  with self.lock:
30
35
  with open(Logger._log_file, 'a', encoding='utf-8') as f:
@@ -1,7 +1,16 @@
1
1
  import json
2
2
 
3
+ from enum import Enum
4
+
3
5
 
4
6
  class BaseModel:
5
- def __str__(self) -> str:
6
- return json.dumps(self, default=lambda o: o.__dict__ if hasattr(o, '__dict__') else str(o), indent=4,
7
- sort_keys=True)
7
+ def __str__(self, enum_as_name=False) -> str:
8
+ def serialize(o):
9
+ if isinstance(o, Enum):
10
+ return o.name if enum_as_name else o.value
11
+ elif hasattr(o, '__dict__'):
12
+ return o.__dict__
13
+ else:
14
+ return str(o)
15
+
16
+ return json.dumps(self, default=serialize, indent=4, sort_keys=True)
@@ -69,7 +69,6 @@ class Result(BaseModel):
69
69
  self.id: str = str(uuid.uuid4())
70
70
  self.title: str = title
71
71
  self.signature: str = signature
72
- self.run_id: Optional[str] = None
73
72
  self.testops_ids: Optional[List[int]] = None
74
73
  self.execution: Type[Execution] = Execution()
75
74
  self.fields: Dict[Type[Field]] = {}
@@ -77,11 +76,9 @@ class Result(BaseModel):
77
76
  self.steps: List[Type[Step]] = []
78
77
  self.params: Optional[dict] = {}
79
78
  self.param_groups: Optional[List[List[str]]] = []
80
- self.author: Optional[str] = None
81
79
  self.relations: Type[Relation] = None
82
80
  self.muted: bool = False
83
81
  self.message: Optional[str] = None
84
- QaseUtils.get_host_data()
85
82
 
86
83
  def add_message(self, message: str) -> None:
87
84
  self.message = message
@@ -123,6 +120,3 @@ class Result(BaseModel):
123
120
 
124
121
  def get_duration(self) -> int:
125
122
  return self.execution.duration
126
-
127
- def set_run_id(self, run_id: str) -> None:
128
- self.run_id = run_id
@@ -1,5 +1,3 @@
1
- import json
2
-
3
1
  from typing import Optional, List
4
2
 
5
3
  from .basemodel import BaseModel
@@ -71,6 +69,7 @@ class Run(BaseModel):
71
69
  "duration": result["execution"]["duration"],
72
70
  "thread": result["execution"]["thread"]
73
71
  }
72
+ self._extract_path_from_relations(result)
74
73
  self.results.append(compact_result)
75
74
  self.execution.track(result)
76
75
  self.stats.track(result)
@@ -79,3 +78,16 @@ class Run(BaseModel):
79
78
 
80
79
  def add_host_data(self, host_data: dict):
81
80
  self.host_data = host_data
81
+
82
+ def _extract_path_from_relations(self, relations_dict):
83
+
84
+ titles = []
85
+ if "relations" in relations_dict and "suite" in relations_dict["relations"]:
86
+ if "data" in relations_dict["relations"]["suite"]:
87
+ data_list = relations_dict["relations"]["suite"]["data"]
88
+ titles = [item["title"] for item in data_list if "title" in item]
89
+
90
+ path = "/".join(titles)
91
+
92
+ if path and path not in self.suites:
93
+ self.suites.append(path)
@@ -20,6 +20,7 @@ class StepTextData(BaseModel):
20
20
  def __init__(self, action: str, expected_result: Optional[str] = None):
21
21
  self.action = action
22
22
  self.expected_result = expected_result
23
+ self.input_data = None
23
24
 
24
25
 
25
26
  class StepAssertData(BaseModel):
@@ -78,6 +79,7 @@ class StepExecution(BaseModel):
78
79
  self.status = status
79
80
  self.end_time = end_time
80
81
  self.duration = duration
82
+ self.attachments = []
81
83
 
82
84
  def set_status(self, status: Optional[str]):
83
85
  if status in ['passed', 'failed', 'skipped', 'blocked', 'untested']:
@@ -89,6 +91,9 @@ class StepExecution(BaseModel):
89
91
  self.end_time = time.time()
90
92
  self.duration = int((self.end_time - self.start_time) * 1000)
91
93
 
94
+ def add_attachment(self, attachment: Attachment):
95
+ self.attachments.append(attachment)
96
+
92
97
 
93
98
  class Step(BaseModel):
94
99
  def __init__(self,
@@ -107,7 +112,6 @@ class Step(BaseModel):
107
112
  self.data = data
108
113
  self.parent_id = parent_id
109
114
  self.execution = StepExecution()
110
- self.attachments = []
111
115
  self.steps = []
112
116
 
113
117
  def set_parent_id(self, parent_id: Optional[str]):
@@ -132,4 +136,4 @@ class Step(BaseModel):
132
136
  self.steps = steps
133
137
 
134
138
  def add_attachment(self, attachment: Attachment):
135
- self.attachments.append(attachment)
139
+ self.execution.add_attachment(attachment)
@@ -41,7 +41,6 @@ class QaseReport:
41
41
  pass
42
42
 
43
43
  def add_result(self, result: Result):
44
- result.set_run_id(self.run_id)
45
44
  for attachment in result.attachments:
46
45
  self._persist_attachment(attachment)
47
46
 
@@ -84,8 +83,8 @@ class QaseReport:
84
83
 
85
84
  def _persist_attachments_in_steps(self, steps: list):
86
85
  for step in steps:
87
- if step.attachments:
88
- for attachment in step.attachments:
86
+ if step.execution.attachments:
87
+ for attachment in step.execution.attachments:
89
88
  self._persist_attachment(attachment)
90
89
  if step.steps:
91
90
  self._persist_attachments_in_steps(step.steps)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qase-python-commons
3
- Version: 3.4.0
3
+ Version: 3.4.2
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
@@ -1,20 +1,20 @@
1
1
  qase/commons/__init__.py,sha256=3HI65PJES4Q6YvtkSuRPh6tZboTETJo8wbdHlNYaePU,323
2
- qase/commons/config.py,sha256=oRIjwNogSRCKQEXzi3AvF-Rg4btEFzR521P-Degp7x4,9052
2
+ qase/commons/config.py,sha256=n0tNGtOsJqaUDe_XBtKoAqgTlBf3AwVR8ddwTTf5N8o,9100
3
3
  qase/commons/loader.py,sha256=-MMY4HgSI6q1xq3NaJoq_w4liM73qdFKjYLVCT1E7Pc,1064
4
- qase/commons/logger.py,sha256=K_8kE0EqpFbF2RbRU5TBw4Hl6GfK6PacpwkRXqHabl0,1234
4
+ qase/commons/logger.py,sha256=KEQr8G0eFZxlI3LJIaaNWOKD8o3NhKsZD06swXFn3FI,1313
5
5
  qase/commons/utils.py,sha256=OOr6kQ5hPZEyHXwbwiTOTkonRxmmtkyZPPGqXQKp5vY,2799
6
6
  qase/commons/client/api_v1_client.py,sha256=9dJsUUM81LhmA2FWTGjWxS9tnBDcf9B6KFVZjCJDB98,6168
7
- qase/commons/client/api_v2_client.py,sha256=X_T9LrDf4NIYjuv8nuVnNxENZDq1fWBJTJ5KsZLF5WU,8556
7
+ qase/commons/client/api_v2_client.py,sha256=wJfPrh_mp1kANyzBotzeOgNQ2VV5oKVMGY6yHpysGbU,8556
8
8
  qase/commons/client/base_api_client.py,sha256=H8JnjqSrBFNfghDd3T3zxYOyKYHYe9QiJQXol1JqdQk,2613
9
9
  qase/commons/exceptions/reporter.py,sha256=dP-Mwcq8HKBOjgu3YqhyULDmDGU09BmT6Fh9HjICaUc,45
10
10
  qase/commons/models/__init__.py,sha256=FTt5dYASBX4r6-tQi-_JAUVx4uvJs9GTxROdAZEV6Jo,272
11
11
  qase/commons/models/attachment.py,sha256=Rjq1mAP11uk7TN2RrtImntw6DUMV7U0R-44TYj8O5j0,1432
12
- qase/commons/models/basemodel.py,sha256=nyDSXhpQUecKdzhB-eWqujmso20oXB9p_42qpOsGVuQ,213
12
+ qase/commons/models/basemodel.py,sha256=0j8E-LE6hxAKQPYLNM9qThor9s2ZndZys_kibeoLImo,426
13
13
  qase/commons/models/relation.py,sha256=HymHeh1uBcoQnTs4Vra7WJ_KFkhryj5o7cShjoGQImI,511
14
- qase/commons/models/result.py,sha256=0BWFGRacYtCQdno85kqFH2VAwwDh2ZWMm7WbZS77fxE,3968
15
- qase/commons/models/run.py,sha256=KkplvlHJNvVLORzVkdz5mHsLFBTUAdtuEYCqCy_RcvU,2469
14
+ qase/commons/models/result.py,sha256=Lw7KIe16BOfPG0zJdg-_JGvnaN8tXPczFC49DCn9YSA,3773
15
+ qase/commons/models/run.py,sha256=nU_FX_YKqJWSyM6QfJpPjhDO-DMz_JXcEVyJ8AzMJN4,3007
16
16
  qase/commons/models/runtime.py,sha256=mfK-mOViD1orXOx-jP6nIgtnN0tUmRYY1aMH0qFDmXA,1287
17
- qase/commons/models/step.py,sha256=M-btRYZ4febYavDhwFqmKcCdLAgrhtuv7E_M3TKZdfg,4281
17
+ qase/commons/models/step.py,sha256=gEvqbs1kZB5NIqm6vzNuOXlJXFdTiSlANuM_0lbssL0,4417
18
18
  qase/commons/models/config/api.py,sha256=IyYY2f3ncESUAEGvkE3-meatebBFJdvgo7KNOQnxLE0,288
19
19
  qase/commons/models/config/batch.py,sha256=X0H8SVOCCD2pV6LSMqjI-tIjRcLifnrM5MareK2FhQw,321
20
20
  qase/commons/models/config/connection.py,sha256=wK2fGjc0G0rMVVhPnjw_t_M1YWZwANlhwl-awmI7XSo,516
@@ -30,12 +30,12 @@ qase/commons/profilers/network.py,sha256=zKNBnTQG4BMg8dn8O--tQzQLpu-qs5ADhHEnqIa
30
30
  qase/commons/profilers/sleep.py,sha256=HT6h0R-2XHZAoBYRxS2T_KC8RrnEoVjP7MXusaE4Nec,1624
31
31
  qase/commons/reporters/__init__.py,sha256=J0aNLzb_MPPT_zF8BtX_w9nj_U7Ad06RGpyWK5Pxq1o,169
32
32
  qase/commons/reporters/core.py,sha256=sirQ9CwLNtxLCrqXEm9dOQf8N9zDIVXofo9IKc0Sh88,8230
33
- qase/commons/reporters/report.py,sha256=zyGeUOcJCOEoGtsewCOf3kypbPttJH7EM-LmZ_Y5huY,4829
33
+ qase/commons/reporters/report.py,sha256=ZLwtVn5gjwgJFtfbpLUO-vW3M3skEq3AhKJwtmM0nUw,4810
34
34
  qase/commons/reporters/testops.py,sha256=JRsAGZPtV8kr_fhsgM0cHqPdh9Ojp2qtpJvHGW9FLq4,6200
35
35
  qase/commons/util/__init__.py,sha256=0sRRfrMOIPCHpk9tXM94Pj10qrk18B61qEcbLpRjw_I,74
36
36
  qase/commons/util/host_data.py,sha256=n8o5PDs8kELCZZ5GR7Jug6LsgZHWJudU7iRmZHRdrlw,5264
37
37
  qase/commons/validators/base.py,sha256=wwSn-4YiuXtfGMGnSKgo9Vm5hAKevVmmfd2Ro6Q7MYQ,173
38
- qase_python_commons-3.4.0.dist-info/METADATA,sha256=mZqLZiNqmif93rQkb9RyYPH1lEn9burKxCVnA8BrshE,1857
39
- qase_python_commons-3.4.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
40
- qase_python_commons-3.4.0.dist-info/top_level.txt,sha256=Mn5aFk7H7Uia4s1NRDsvebu8vCrFy9nOuRIBfkIY5kQ,5
41
- qase_python_commons-3.4.0.dist-info/RECORD,,
38
+ qase_python_commons-3.4.2.dist-info/METADATA,sha256=d13o-AT7skEQYEl7AOqrVL6yWCZJkKTm3ia9VhWk2m0,1857
39
+ qase_python_commons-3.4.2.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
40
+ qase_python_commons-3.4.2.dist-info/top_level.txt,sha256=Mn5aFk7H7Uia4s1NRDsvebu8vCrFy9nOuRIBfkIY5kQ,5
41
+ qase_python_commons-3.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5