orangebeard-client 1.2.0__tar.gz → 2.0.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.
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/PKG-INFO +3 -1
- orangebeard-client-2.0.0/orangebeard/OrangebeardClient.py +425 -0
- orangebeard-client-2.0.0/orangebeard/__init__.py +5 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/Attachment.py +17 -12
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/Attribute.py +3 -2
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/FinishStep.py +2 -4
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/FinishTest.py +2 -3
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/FinishTestRun.py +1 -1
- orangebeard-client-2.0.0/orangebeard/entity/Log.py +14 -0
- orangebeard-client-2.0.0/orangebeard/entity/SUTComponent.py +11 -0
- orangebeard-client-2.0.0/orangebeard/entity/Serializable.py +24 -0
- orangebeard-client-2.0.0/orangebeard/entity/StartStep.py +21 -0
- orangebeard-client-2.0.0/orangebeard/entity/StartSuite.py +20 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/StartTest.py +9 -8
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/StartTestRun.py +7 -5
- orangebeard-client-2.0.0/orangebeard/entity/Suite.py +16 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard_client.egg-info/PKG-INFO +3 -1
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard_client.egg-info/SOURCES.txt +3 -2
- orangebeard-client-2.0.0/orangebeard_client.egg-info/requires.txt +2 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/pyproject.toml +2 -2
- orangebeard-client-2.0.0/tests/test.py +120 -0
- orangebeard-client-1.2.0/orangebeard/__init__.py +0 -5
- orangebeard-client-1.2.0/orangebeard/async_client.py +0 -408
- orangebeard-client-1.2.0/orangebeard/client.py +0 -307
- orangebeard-client-1.2.0/orangebeard/entity/Log.py +0 -14
- orangebeard-client-1.2.0/orangebeard/entity/Serializable.py +0 -6
- orangebeard-client-1.2.0/orangebeard/entity/StartStep.py +0 -20
- orangebeard-client-1.2.0/orangebeard/entity/StartSuite.py +0 -18
- orangebeard-client-1.2.0/orangebeard_client.egg-info/requires.txt +0 -1
- orangebeard-client-1.2.0/tests/test.py +0 -68
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/LICENSE +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/README.md +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/LogFormat.py +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/LogLevel.py +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/TestStatus.py +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/TestType.py +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard/entity/__init__.py +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard_client.egg-info/dependency_links.txt +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/orangebeard_client.egg-info/top_level.txt +0 -0
- {orangebeard-client-1.2.0 → orangebeard-client-2.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: orangebeard-client
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: A python3 client for Orangebeard
|
|
5
5
|
Author-email: Tom Heintzberger <tom@orangebeard.io>
|
|
6
6
|
Project-URL: Homepage, https://github.com/orangebeard-io/python-client
|
|
@@ -11,6 +11,8 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.7
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
+
Requires-Dist: pytz
|
|
15
|
+
Requires-Dist: aiohttp
|
|
14
16
|
|
|
15
17
|
<h1 align="center">
|
|
16
18
|
<a href="https://github.com/orangebeard-io/python-client">
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import uuid
|
|
3
|
+
from asyncio.locks import Event
|
|
4
|
+
from types import MappingProxyType
|
|
5
|
+
|
|
6
|
+
import aiohttp
|
|
7
|
+
|
|
8
|
+
from uuid import UUID
|
|
9
|
+
|
|
10
|
+
from aiohttp import ContentTypeError
|
|
11
|
+
|
|
12
|
+
from orangebeard.entity.Attachment import Attachment
|
|
13
|
+
from orangebeard.entity.FinishStep import FinishStep
|
|
14
|
+
from orangebeard.entity.FinishTest import FinishTest
|
|
15
|
+
from orangebeard.entity.FinishTestRun import FinishTestRun
|
|
16
|
+
from orangebeard.entity.Log import Log
|
|
17
|
+
from orangebeard.entity.Serializable import Serializable
|
|
18
|
+
from orangebeard.entity.StartStep import StartStep
|
|
19
|
+
from orangebeard.entity.StartSuite import StartSuite
|
|
20
|
+
from orangebeard.entity.StartTest import StartTest
|
|
21
|
+
from orangebeard.entity.StartTestRun import StartTestRun
|
|
22
|
+
from orangebeard.entity.Suite import Suite
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class OrangebeardClient:
|
|
26
|
+
"""
|
|
27
|
+
OrangebeardClient class for interacting with the Orangebeard API.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
endpoint (str): The Orangebeard API endpoint.
|
|
31
|
+
access_token (UUID): The access token for authentication.
|
|
32
|
+
project_name (str): The name of the Orangebeard project.
|
|
33
|
+
|
|
34
|
+
Attributes:
|
|
35
|
+
__endpoint (str): The Orangebeard API endpoint.
|
|
36
|
+
__access_token (UUID): The access token for authentication.
|
|
37
|
+
__project_name (str): The name of the Orangebeard project.
|
|
38
|
+
__connection_with_orangebeard_is_valid (bool): Flag indicating whether the connection with
|
|
39
|
+
Orangebeard is valid.
|
|
40
|
+
__uuid_mapping (dict): Mapping of temporary UUIDs to actual UUIDs.
|
|
41
|
+
__call_events (dict): Mapping of UUIDs to asyncio.Event objects.
|
|
42
|
+
__client (aiohttp.ClientSession): A client session for making API requests.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
endpoint: str,
|
|
48
|
+
access_token: UUID,
|
|
49
|
+
project_name: str
|
|
50
|
+
) -> None:
|
|
51
|
+
"""
|
|
52
|
+
Initialize the OrangebeardClient.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
endpoint (str): The Orangebeard API endpoint.
|
|
56
|
+
access_token (UUID): The access token for authentication.
|
|
57
|
+
project_name (str): The name of the Orangebeard project.
|
|
58
|
+
"""
|
|
59
|
+
self.__endpoint = endpoint
|
|
60
|
+
self.__access_token = access_token
|
|
61
|
+
self.__project_name = project_name
|
|
62
|
+
self.__connection_with_orangebeard_is_valid: bool = True
|
|
63
|
+
|
|
64
|
+
self.__uuid_mapping = {}
|
|
65
|
+
self.__call_events = {}
|
|
66
|
+
self.__event_loop = asyncio.new_event_loop()
|
|
67
|
+
asyncio.set_event_loop(self.__event_loop)
|
|
68
|
+
|
|
69
|
+
self.__client = aiohttp.ClientSession(
|
|
70
|
+
base_url=self.__endpoint,
|
|
71
|
+
headers={
|
|
72
|
+
"Authorization": f"Bearer {str(self.__access_token)}",
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
def start_test_run(self, start_test_run: StartTestRun) -> UUID:
|
|
77
|
+
"""
|
|
78
|
+
Start a new test run.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
start_test_run (StartTestRun): The StartTestRun object containing information about the test run.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
UUID: The UUID associated with the started test run.
|
|
85
|
+
"""
|
|
86
|
+
temp_uuid = uuid.uuid4()
|
|
87
|
+
start_test_run_event = asyncio.Event()
|
|
88
|
+
|
|
89
|
+
self.__call_events[temp_uuid] = start_test_run_event
|
|
90
|
+
|
|
91
|
+
self.__event_loop.run_until_complete(self.__exec_start_test_run(start_test_run, temp_uuid))
|
|
92
|
+
return temp_uuid
|
|
93
|
+
|
|
94
|
+
def start_announced_test_run(self, test_run_uuid: UUID) -> None:
|
|
95
|
+
"""
|
|
96
|
+
Start an announced test run.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
test_run_uuid (UUID): The UUID of the test run to be started.
|
|
100
|
+
"""
|
|
101
|
+
start_test_run_event = asyncio.Event()
|
|
102
|
+
self.__call_events[test_run_uuid] = start_test_run_event
|
|
103
|
+
self.__event_loop.run_until_complete(self.__exec_start_announced_test_run(test_run_uuid))
|
|
104
|
+
|
|
105
|
+
def finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
|
|
106
|
+
"""
|
|
107
|
+
Wait for all events to finish and then finish the test run.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
test_run_uuid (UUID): The UUID of the test run to be finished.
|
|
111
|
+
finish_test_run (FinishTestRun): The FinishTestRun object containing information about finishing the
|
|
112
|
+
test run.
|
|
113
|
+
"""
|
|
114
|
+
self.__event_loop.run_until_complete(
|
|
115
|
+
self.__exec_finish_test_run(test_run_uuid, finish_test_run))
|
|
116
|
+
|
|
117
|
+
def start_suite(self, start_suite: StartSuite) -> list[UUID]:
|
|
118
|
+
"""
|
|
119
|
+
Start a suite and return a list of UUIDs associated with the started suites.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
start_suite (StartSuite): The StartSuite object containing information about the suite.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
list[UUID]: List of UUIDs associated with the started suites.
|
|
126
|
+
"""
|
|
127
|
+
start_suite_event = asyncio.Event()
|
|
128
|
+
temp_uuids = [uuid.uuid4() for _ in start_suite.suiteNames]
|
|
129
|
+
for temp_uuid in temp_uuids:
|
|
130
|
+
self.__call_events[temp_uuid] = start_suite_event
|
|
131
|
+
|
|
132
|
+
parent_event_uuid: UUID = start_suite.testRunUUID if start_suite.parentSuiteUUID is None \
|
|
133
|
+
else start_suite.parentSuiteUUID
|
|
134
|
+
parent_event = self.__call_events[parent_event_uuid]
|
|
135
|
+
self.__event_loop.run_until_complete(self.__exec_start_suite(start_suite, temp_uuids, parent_event))
|
|
136
|
+
return temp_uuids
|
|
137
|
+
|
|
138
|
+
def start_test(self, start_test: StartTest) -> UUID:
|
|
139
|
+
"""
|
|
140
|
+
Start a test.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
start_test (StartTest): The StartTest object containing information about the test.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
UUID: The UUID associated with the started test.
|
|
147
|
+
"""
|
|
148
|
+
start_test_event = asyncio.Event()
|
|
149
|
+
temp_uuid = uuid.uuid4()
|
|
150
|
+
self.__call_events[temp_uuid] = start_test_event
|
|
151
|
+
|
|
152
|
+
parent_event = self.__call_events[start_test.suiteUUID]
|
|
153
|
+
self.__event_loop.run_until_complete(self.__exec_start_test(start_test, temp_uuid, parent_event))
|
|
154
|
+
return temp_uuid
|
|
155
|
+
|
|
156
|
+
def finish_test(self, test_uuid: UUID, finish_test: FinishTest) -> None:
|
|
157
|
+
"""
|
|
158
|
+
Finish a test.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
test_uuid (UUID): The UUID of the test to be finished.
|
|
162
|
+
finish_test (FinishTest): The FinishTest object containing information about finishing the test.
|
|
163
|
+
"""
|
|
164
|
+
finish_test_event = asyncio.Event()
|
|
165
|
+
temp_uuid = uuid.uuid4()
|
|
166
|
+
self.__call_events[temp_uuid] = finish_test_event
|
|
167
|
+
|
|
168
|
+
parent_event = self.__call_events[test_uuid]
|
|
169
|
+
asyncio.ensure_future(self.__exec_finish_test(test_uuid, finish_test, temp_uuid, parent_event))
|
|
170
|
+
|
|
171
|
+
def start_step(self, start_step: StartStep) -> UUID:
|
|
172
|
+
"""
|
|
173
|
+
Start a step.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
start_step (StartStep): The StartStep object containing information about the step.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
UUID: The UUID associated with the started step.
|
|
180
|
+
"""
|
|
181
|
+
start_step_event = asyncio.Event()
|
|
182
|
+
temp_uuid = uuid.uuid4()
|
|
183
|
+
self.__call_events[temp_uuid] = start_step_event
|
|
184
|
+
|
|
185
|
+
parent_event_uuid = start_step.testUUID if start_step.parentStepUUID is None \
|
|
186
|
+
else start_step.parentStepUUID
|
|
187
|
+
|
|
188
|
+
parent_event = self.__call_events[parent_event_uuid]
|
|
189
|
+
|
|
190
|
+
self.__event_loop.run_until_complete(self.__exec_start_step(start_step, temp_uuid, parent_event))
|
|
191
|
+
return temp_uuid
|
|
192
|
+
|
|
193
|
+
def finish_step(self, step_uuid: UUID, finish_step: FinishStep) -> None:
|
|
194
|
+
"""
|
|
195
|
+
Finish a step.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
step_uuid (UUID): The UUID of the step to be finished.
|
|
199
|
+
finish_step (FinishStep): The FinishStep object containing information about finishing the step.
|
|
200
|
+
"""
|
|
201
|
+
finish_step_event = asyncio.Event()
|
|
202
|
+
temp_uuid = uuid.uuid4()
|
|
203
|
+
self.__call_events[temp_uuid] = finish_step_event
|
|
204
|
+
|
|
205
|
+
parent_event = self.__call_events[step_uuid]
|
|
206
|
+
asyncio.ensure_future(self.__exec_finish_step(step_uuid, finish_step, temp_uuid, parent_event))
|
|
207
|
+
|
|
208
|
+
def log(self, log: Log) -> UUID:
|
|
209
|
+
"""
|
|
210
|
+
Send a log.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
log (Log): The Log object containing information to store.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
UUID: The UUID associated with the log.
|
|
217
|
+
"""
|
|
218
|
+
log_event = asyncio.Event()
|
|
219
|
+
temp_uuid = uuid.uuid4()
|
|
220
|
+
self.__call_events[temp_uuid] = log_event
|
|
221
|
+
|
|
222
|
+
parent_event_uuid = log.testUUID if log.stepUUID is None \
|
|
223
|
+
else log.stepUUID
|
|
224
|
+
parent_event = self.__call_events[parent_event_uuid]
|
|
225
|
+
|
|
226
|
+
asyncio.ensure_future(self.__exec_log(log, temp_uuid, parent_event))
|
|
227
|
+
return temp_uuid
|
|
228
|
+
|
|
229
|
+
def send_attachment(self, attachment: Attachment) -> UUID:
|
|
230
|
+
"""
|
|
231
|
+
Send an attachment. (to attach to a log)
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
attachment (Attachment): The Attachment object containing information about the attachment.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
UUID: The UUID associated with the attachment that was sent.
|
|
238
|
+
"""
|
|
239
|
+
attachment_event = asyncio.Event()
|
|
240
|
+
temp_uuid = uuid.uuid4()
|
|
241
|
+
self.__call_events[temp_uuid] = attachment_event
|
|
242
|
+
|
|
243
|
+
parent_event = self.__call_events[attachment.AttachmentMetaData.logUUID]
|
|
244
|
+
asyncio.ensure_future(self.__exec_send_attachment(attachment, temp_uuid, parent_event))
|
|
245
|
+
return temp_uuid
|
|
246
|
+
|
|
247
|
+
async def __make_api_request(self, method: str, uri: str, data: Serializable = None):
|
|
248
|
+
if self.__connection_with_orangebeard_is_valid:
|
|
249
|
+
async with self.__client.request(method, uri,
|
|
250
|
+
data=data.to_json() if data is not None else None) as response:
|
|
251
|
+
if 200 <= response.status < 300:
|
|
252
|
+
try:
|
|
253
|
+
return await response.json()
|
|
254
|
+
except ContentTypeError:
|
|
255
|
+
return None
|
|
256
|
+
else:
|
|
257
|
+
print(f'Error Sending: {data.to_json()} to {uri}')
|
|
258
|
+
self.__connection_with_orangebeard_is_valid = False
|
|
259
|
+
raise ConnectionError(f'Failed to communicate with Orangebeard: {await response.text()}')
|
|
260
|
+
|
|
261
|
+
async def __exec_start_test_run(self, start_test_run: StartTestRun, temp_uuid: UUID) -> None:
|
|
262
|
+
response = await self.__make_api_request(
|
|
263
|
+
'POST',
|
|
264
|
+
f'/listener/v3/{self.__project_name}/test-run/start',
|
|
265
|
+
start_test_run
|
|
266
|
+
)
|
|
267
|
+
actual_uuid = response if response else None
|
|
268
|
+
self.__uuid_mapping[temp_uuid] = actual_uuid
|
|
269
|
+
self.__call_events[temp_uuid].set()
|
|
270
|
+
|
|
271
|
+
async def __exec_start_announced_test_run(self, test_run_uuid: UUID) -> None:
|
|
272
|
+
await self.__make_api_request(
|
|
273
|
+
'PUT',
|
|
274
|
+
f'/listener/v3/{self.__project_name}/test-run/start/{test_run_uuid}'
|
|
275
|
+
)
|
|
276
|
+
self.__uuid_mapping[test_run_uuid] = test_run_uuid
|
|
277
|
+
self.__call_events[test_run_uuid].set()
|
|
278
|
+
|
|
279
|
+
async def __exec_finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
|
|
280
|
+
print(f'Waiting for {len(self.__call_events.values()) + 1} Orangebeard events to finish...')
|
|
281
|
+
|
|
282
|
+
for event in self.__call_events.values():
|
|
283
|
+
await event.wait()
|
|
284
|
+
|
|
285
|
+
real_test_run_uuid = self.__uuid_mapping[test_run_uuid]
|
|
286
|
+
await self.__make_api_request(
|
|
287
|
+
'PUT',
|
|
288
|
+
f'/listener/v3/{self.__project_name}/test-run/finish/{real_test_run_uuid}',
|
|
289
|
+
finish_test_run
|
|
290
|
+
)
|
|
291
|
+
print('Done. Test run finished!')
|
|
292
|
+
await self.__client.close()
|
|
293
|
+
|
|
294
|
+
async def __exec_start_suite(self, start_suite: StartSuite, suite_temp_ids: list[UUID],
|
|
295
|
+
parent_event: Event) -> None:
|
|
296
|
+
await parent_event.wait()
|
|
297
|
+
|
|
298
|
+
start_suite.testRunUUID = self.__uuid_mapping[start_suite.testRunUUID]
|
|
299
|
+
if start_suite.parentSuiteUUID is not None:
|
|
300
|
+
start_suite.parentSuiteUUID = self.__uuid_mapping[start_suite.parentSuiteUUID]
|
|
301
|
+
|
|
302
|
+
suites: list[Suite] = await self.__make_api_request(
|
|
303
|
+
'POST',
|
|
304
|
+
f'/listener/v3/{self.__project_name}/suite/start',
|
|
305
|
+
start_suite
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
actual_uuids = [suite['suiteUUID'] for suite in suites]
|
|
309
|
+
for i, temp_uuid in enumerate(suite_temp_ids):
|
|
310
|
+
self.__uuid_mapping[temp_uuid] = actual_uuids[i]
|
|
311
|
+
self.__call_events[temp_uuid].set()
|
|
312
|
+
|
|
313
|
+
async def __exec_start_test(self, start_test: StartTest, temp_uuid: UUID, parent_event: Event) -> None:
|
|
314
|
+
await parent_event.wait()
|
|
315
|
+
start_test.testRunUUID = self.__uuid_mapping[start_test.testRunUUID]
|
|
316
|
+
start_test.suiteUUID = self.__uuid_mapping[start_test.suiteUUID]
|
|
317
|
+
|
|
318
|
+
response = await self.__make_api_request(
|
|
319
|
+
'POST',
|
|
320
|
+
f'/listener/v3/{self.__project_name}/test/start',
|
|
321
|
+
start_test
|
|
322
|
+
)
|
|
323
|
+
actual_uuid = response if response else None
|
|
324
|
+
self.__uuid_mapping[temp_uuid] = actual_uuid
|
|
325
|
+
self.__call_events[temp_uuid].set()
|
|
326
|
+
|
|
327
|
+
async def __exec_finish_test(self, test_uuid: UUID, finish_test: FinishTest, temp_uuid: UUID,
|
|
328
|
+
parent_event: Event) -> None:
|
|
329
|
+
await parent_event.wait()
|
|
330
|
+
test_uuid = self.__uuid_mapping[test_uuid]
|
|
331
|
+
finish_test.testRunUUID = self.__uuid_mapping[finish_test.testRunUUID]
|
|
332
|
+
|
|
333
|
+
await self.__make_api_request(
|
|
334
|
+
'PUT',
|
|
335
|
+
f'/listener/v3/{self.__project_name}/test/finish/{test_uuid}',
|
|
336
|
+
finish_test
|
|
337
|
+
)
|
|
338
|
+
self.__call_events[temp_uuid].set()
|
|
339
|
+
|
|
340
|
+
async def __exec_start_step(self, start_step: StartStep, temp_uuid: UUID, parent_event: Event) -> None:
|
|
341
|
+
await parent_event.wait()
|
|
342
|
+
start_step.testRunUUID = self.__uuid_mapping[start_step.testRunUUID]
|
|
343
|
+
start_step.testUUID = self.__uuid_mapping[start_step.testUUID]
|
|
344
|
+
if start_step.parentStepUUID is not None:
|
|
345
|
+
start_step.parentStepUUID = self.__uuid_mapping[start_step.parentStepUUID]
|
|
346
|
+
|
|
347
|
+
response = await self.__make_api_request(
|
|
348
|
+
'POST',
|
|
349
|
+
f'/listener/v3/{self.__project_name}/step/start',
|
|
350
|
+
start_step
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
actual_uuid = response if response else None
|
|
354
|
+
self.__uuid_mapping[temp_uuid] = actual_uuid
|
|
355
|
+
self.__call_events[temp_uuid].set()
|
|
356
|
+
|
|
357
|
+
async def __exec_finish_step(self, step_uuid: UUID, finish_step: FinishStep, temp_uuid: UUID,
|
|
358
|
+
parent_event: Event) -> None:
|
|
359
|
+
await parent_event.wait()
|
|
360
|
+
step_uuid = self.__uuid_mapping[step_uuid]
|
|
361
|
+
finish_step.testRunUUID = self.__uuid_mapping[finish_step.testRunUUID]
|
|
362
|
+
|
|
363
|
+
await self.__make_api_request(
|
|
364
|
+
'PUT',
|
|
365
|
+
f'/listener/v3/{self.__project_name}/step/finish/{step_uuid}',
|
|
366
|
+
finish_step
|
|
367
|
+
)
|
|
368
|
+
self.__call_events[temp_uuid].set()
|
|
369
|
+
|
|
370
|
+
async def __exec_log(self, log: Log, temp_uuid: UUID, parent_event: Event) -> None:
|
|
371
|
+
await parent_event.wait()
|
|
372
|
+
log.testRunUUID = self.__uuid_mapping[log.testRunUUID]
|
|
373
|
+
log.testUUID = self.__uuid_mapping[log.testUUID]
|
|
374
|
+
log.stepUUID = self.__uuid_mapping[log.stepUUID] if log.stepUUID is not None else None
|
|
375
|
+
|
|
376
|
+
response = await self.__make_api_request(
|
|
377
|
+
'POST',
|
|
378
|
+
f'/listener/v3/{self.__project_name}/log',
|
|
379
|
+
log
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
actual_uuid = response if response else None
|
|
383
|
+
self.__uuid_mapping[temp_uuid] = actual_uuid
|
|
384
|
+
self.__call_events[temp_uuid].set()
|
|
385
|
+
|
|
386
|
+
async def __exec_send_attachment(self, attachment: Attachment, temp_uuid: UUID, parent_event: Event) -> None:
|
|
387
|
+
await parent_event.wait()
|
|
388
|
+
attachment.AttachmentMetaData.testRunUUID = self.__uuid_mapping[attachment.AttachmentMetaData.testRunUUID]
|
|
389
|
+
attachment.AttachmentMetaData.testUUID = self.__uuid_mapping[attachment.AttachmentMetaData.testUUID]
|
|
390
|
+
if attachment.AttachmentMetaData.stepUUID is not None:
|
|
391
|
+
attachment.AttachmentMetaData.stepUUID = self.__uuid_mapping[attachment.AttachmentMetaData.stepUUID]
|
|
392
|
+
attachment.AttachmentMetaData.logUUID = self.__uuid_mapping[attachment.AttachmentMetaData.logUUID]
|
|
393
|
+
|
|
394
|
+
if self.__connection_with_orangebeard_is_valid:
|
|
395
|
+
boundary = f"boundary_{uuid.uuid4().hex}"
|
|
396
|
+
multipart_message = aiohttp.MultipartWriter('form-data', boundary=boundary)
|
|
397
|
+
|
|
398
|
+
multipart_message.append(
|
|
399
|
+
attachment.AttachmentMetaData.to_json(),
|
|
400
|
+
MappingProxyType({'Content-Disposition': 'form-data; name="json"', 'Content-Type': 'application/json'})
|
|
401
|
+
)
|
|
402
|
+
multipart_message.append(
|
|
403
|
+
attachment.AttachmentFile.content,
|
|
404
|
+
MappingProxyType({
|
|
405
|
+
'Content-Disposition': f'form-data; name="attachment"; filename="{attachment.AttachmentFile.name}"',
|
|
406
|
+
'Content-Type': attachment.AttachmentFile.contentType
|
|
407
|
+
})
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
headers = {
|
|
411
|
+
'Authorization': f'Bearer {str(self.__access_token)}',
|
|
412
|
+
'Content-Type': f'multipart/form-data; boundary={boundary}'
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
uri = f'/listener/v3/{self.__project_name}/attachment'
|
|
416
|
+
|
|
417
|
+
async with self.__client.request('POST', uri, data=multipart_message, headers=headers) as response:
|
|
418
|
+
if 200 <= response.status < 300:
|
|
419
|
+
response_text = await response.text()
|
|
420
|
+
actual_uuid = response_text if response_text else None
|
|
421
|
+
self.__uuid_mapping[temp_uuid] = actual_uuid
|
|
422
|
+
self.__call_events[temp_uuid].set()
|
|
423
|
+
else:
|
|
424
|
+
self.__connection_with_orangebeard_is_valid = False
|
|
425
|
+
raise ConnectionError(f'Failed to communicate with Orangebeard: {await response.text()}')
|
|
@@ -3,13 +3,18 @@ import mimetypes
|
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
from pytz import reference
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
from orangebeard.entity.Serializable import Serializable
|
|
8
7
|
|
|
9
8
|
tz = reference.LocalTimezone()
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
class
|
|
11
|
+
class Attachment(Serializable):
|
|
12
|
+
def __init__(self, file, meta_data):
|
|
13
|
+
self.AttachmentFile: AttachmentFile = file
|
|
14
|
+
self.AttachmentMetaData: AttachmentMetaData = meta_data
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AttachmentFile(Serializable):
|
|
13
18
|
def __init__(self, name, content):
|
|
14
19
|
self.name = name
|
|
15
20
|
self.content: bytes = content
|
|
@@ -18,17 +23,17 @@ class AttachmentFile:
|
|
|
18
23
|
|
|
19
24
|
class AttachmentMetaData(Serializable):
|
|
20
25
|
def __init__(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
self,
|
|
27
|
+
testRunUUID: UUID,
|
|
28
|
+
testUUID: UUID,
|
|
29
|
+
logUUID: UUID,
|
|
30
|
+
stepUUID: UUID = None, # type: ignore
|
|
31
|
+
attachmentTime=None,
|
|
27
32
|
):
|
|
28
|
-
self.testRunUUID =
|
|
29
|
-
self.testUUID =
|
|
30
|
-
self.stepUUID =
|
|
31
|
-
self.logUUID =
|
|
33
|
+
self.testRunUUID = testRunUUID
|
|
34
|
+
self.testUUID = testUUID
|
|
35
|
+
self.stepUUID = stepUUID if stepUUID else None
|
|
36
|
+
self.logUUID = logUUID
|
|
32
37
|
self.attachmentTime = (
|
|
33
38
|
attachmentTime.strftime("%Y-%m-%dT%H:%M:%S%z")
|
|
34
39
|
if attachmentTime
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
1
|
from orangebeard.entity.Serializable import Serializable
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
class FinishStep(Serializable):
|
|
7
5
|
def __init__(self, testRunUUID, status, endTime):
|
|
8
|
-
self.testRunUUID =
|
|
6
|
+
self.testRunUUID = testRunUUID
|
|
9
7
|
self.status = status
|
|
10
|
-
self.endTime = endTime.strftime("%Y-%m-%dT%H:%M:%S%z")
|
|
8
|
+
self.endTime = endTime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
1
|
from uuid import UUID
|
|
3
2
|
|
|
4
3
|
from orangebeard.entity.Serializable import Serializable
|
|
@@ -6,6 +5,6 @@ from orangebeard.entity.Serializable import Serializable
|
|
|
6
5
|
|
|
7
6
|
class FinishTest(Serializable):
|
|
8
7
|
def __init__(self, testRunUUID: UUID, status, endTime):
|
|
9
|
-
self.testRunUUID =
|
|
8
|
+
self.testRunUUID = testRunUUID
|
|
10
9
|
self.status = status
|
|
11
|
-
self.endTime = endTime.strftime("%Y-%m-%dT%H:%M:%S%z")
|
|
10
|
+
self.endTime = endTime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from orangebeard.entity.Serializable import Serializable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Log(Serializable):
|
|
5
|
+
def __init__(
|
|
6
|
+
self, testRunUUID, testUUID, message, logLevel, logFormat, stepUUID, logTime
|
|
7
|
+
):
|
|
8
|
+
self.testRunUUID = testRunUUID
|
|
9
|
+
self.testUUID = testUUID
|
|
10
|
+
self.stepUUID = stepUUID if stepUUID else None
|
|
11
|
+
self.logTime = logTime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|
|
12
|
+
self.message = message
|
|
13
|
+
self.logLevel = logLevel
|
|
14
|
+
self.logFormat = logFormat
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from orangebeard.entity.Serializable import Serializable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SUTComponent(Serializable):
|
|
5
|
+
def __init__(self, componentId, componentName, version, status, createdDateTime, updatedDateTime):
|
|
6
|
+
self.componentId = componentId
|
|
7
|
+
self.componentName = componentName
|
|
8
|
+
self.version = version
|
|
9
|
+
self.status = status
|
|
10
|
+
self.createDateTime = createdDateTime.strftime("%Y-%m-%d %H:%M:%S%z")
|
|
11
|
+
self.updateDateTime = updatedDateTime.strftime("%Y-%m-%d %H:%M:%S%z")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Serializable:
|
|
6
|
+
|
|
7
|
+
def __make_serializable(self):
|
|
8
|
+
serializable_dict = {}
|
|
9
|
+
for key, value in self.__dict__.items():
|
|
10
|
+
if isinstance(value, UUID):
|
|
11
|
+
serializable_dict[key] = str(value)
|
|
12
|
+
else:
|
|
13
|
+
if value is not None:
|
|
14
|
+
serializable_dict[key] = value
|
|
15
|
+
return serializable_dict
|
|
16
|
+
|
|
17
|
+
def __getitem__(self, key):
|
|
18
|
+
try:
|
|
19
|
+
return getattr(self, key)
|
|
20
|
+
except AttributeError:
|
|
21
|
+
raise KeyError(f'[{key}] not found in {self.__class__.__name__}')
|
|
22
|
+
|
|
23
|
+
def to_json(self):
|
|
24
|
+
return json.dumps(self.__make_serializable(), default=lambda o: o.__dict__)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
from orangebeard.entity.Serializable import Serializable
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StartStep(Serializable):
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
testRunUUID: UUID,
|
|
10
|
+
testUUID: UUID,
|
|
11
|
+
stepName: str,
|
|
12
|
+
startTime: datetime,
|
|
13
|
+
parentStepUUID: UUID = None,
|
|
14
|
+
description: str = None,
|
|
15
|
+
):
|
|
16
|
+
self.testRunUUID = testRunUUID
|
|
17
|
+
self.testUUID = testUUID
|
|
18
|
+
self.parentStepUUID = parentStepUUID if parentStepUUID else None
|
|
19
|
+
self.stepName = stepName
|
|
20
|
+
self.description = description
|
|
21
|
+
self.startTime = startTime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
|
|
3
|
+
from orangebeard.entity.Attribute import Attribute
|
|
4
|
+
from orangebeard.entity.Serializable import Serializable
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class StartSuite(Serializable):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
testRunUUID: UUID,
|
|
11
|
+
suiteNames: list[str],
|
|
12
|
+
parentSuiteUUID: UUID = None,
|
|
13
|
+
description: str = None,
|
|
14
|
+
attributes: list[Attribute] = None,
|
|
15
|
+
):
|
|
16
|
+
self.testRunUUID = testRunUUID
|
|
17
|
+
self.parentSuiteUUID = parentSuiteUUID if parentSuiteUUID else None
|
|
18
|
+
self.description = description
|
|
19
|
+
self.attributes = attributes
|
|
20
|
+
self.suiteNames = suiteNames
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
from typing import List
|
|
2
3
|
from uuid import UUID
|
|
3
4
|
from orangebeard.entity.Attribute import Attribute
|
|
@@ -10,16 +11,16 @@ class StartTest(Serializable):
|
|
|
10
11
|
self,
|
|
11
12
|
testRunUUID: UUID,
|
|
12
13
|
suiteUUID: UUID,
|
|
13
|
-
testName,
|
|
14
|
-
startTime,
|
|
14
|
+
testName: str,
|
|
15
|
+
startTime: datetime,
|
|
15
16
|
testType: TestType,
|
|
16
|
-
|
|
17
|
-
attributes: List[Attribute],
|
|
17
|
+
description: str = None,
|
|
18
|
+
attributes: List[Attribute] = None,
|
|
18
19
|
):
|
|
19
|
-
self.testRunUUID =
|
|
20
|
-
self.suiteUUID =
|
|
20
|
+
self.testRunUUID = testRunUUID
|
|
21
|
+
self.suiteUUID = suiteUUID
|
|
21
22
|
self.testName = testName
|
|
22
23
|
self.testType = testType
|
|
23
|
-
self.
|
|
24
|
+
self.description = description
|
|
24
25
|
self.attributes = attributes
|
|
25
|
-
self.startTime = startTime.strftime("%Y-%m-%dT%H:%M:%S%z")
|
|
26
|
+
self.startTime = startTime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|