orangebeard-client 2.1.1__tar.gz → 2.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.
Files changed (33) hide show
  1. {orangebeard-client-2.1.1/orangebeard_client.egg-info → orangebeard_client-2.3.0}/PKG-INFO +1 -1
  2. orangebeard_client-2.3.0/orangebeard/Cli.py +57 -0
  3. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/OrangebeardClient.py +56 -20
  4. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/config/AutoConfig.py +1 -0
  5. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/OrangebeardParameters.py +3 -1
  6. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0/orangebeard_client.egg-info}/PKG-INFO +1 -1
  7. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard_client.egg-info/SOURCES.txt +2 -0
  8. orangebeard_client-2.3.0/orangebeard_client.egg-info/entry_points.txt +2 -0
  9. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/pyproject.toml +4 -1
  10. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/LICENSE +0 -0
  11. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/__init__.py +0 -0
  12. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/Attachment.py +0 -0
  13. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/Attribute.py +0 -0
  14. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/FinishStep.py +0 -0
  15. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/FinishTest.py +0 -0
  16. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/FinishTestRun.py +0 -0
  17. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/Log.py +0 -0
  18. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/LogFormat.py +0 -0
  19. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/LogLevel.py +0 -0
  20. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/SUTComponent.py +0 -0
  21. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/Serializable.py +0 -0
  22. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/StartStep.py +0 -0
  23. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/StartSuite.py +0 -0
  24. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/StartTest.py +0 -0
  25. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/StartTestRun.py +0 -0
  26. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/Suite.py +0 -0
  27. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/TestStatus.py +0 -0
  28. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/TestType.py +0 -0
  29. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard/entity/__init__.py +0 -0
  30. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard_client.egg-info/dependency_links.txt +0 -0
  31. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard_client.egg-info/requires.txt +0 -0
  32. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/orangebeard_client.egg-info/top_level.txt +0 -0
  33. {orangebeard-client-2.1.1 → orangebeard_client-2.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: orangebeard-client
3
- Version: 2.1.1
3
+ Version: 2.3.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
@@ -0,0 +1,57 @@
1
+ import argparse
2
+ import asyncio
3
+ import sys
4
+
5
+ from datetime import datetime
6
+
7
+ from orangebeard.OrangebeardClient import OrangebeardClient
8
+ from orangebeard.config import AutoConfig
9
+ from orangebeard.entity.FinishTestRun import FinishTestRun
10
+ from orangebeard.entity.StartTestRun import StartTestRun
11
+ from pytz import reference
12
+
13
+ tz = reference.LocalTimezone()
14
+
15
+
16
+ def main():
17
+ config = AutoConfig.config
18
+
19
+ parser = argparse.ArgumentParser(prog="Orangebeard CommandLine Utility",
20
+ description="CLI to start or finish a test run")
21
+ parser.add_argument('-e', '--endpoint', help="Your Orangebeard endpoint", default=config.endpoint)
22
+ parser.add_argument('-t', '--accessToken', help="Your Orangebeard Access Token", default=config.token)
23
+ parser.add_argument('-p', '--project', help="Orangebeard Project Name", default=config.project)
24
+ parser.add_argument('-x', '--cmd', required=True, choices=['start', 'finish'], help="Command to execute")
25
+ parser.add_argument('-s', '--testset', help="The testset name, required for start command", default=config.testset)
26
+ parser.add_argument('-d', '--description', help="The test run description", default=config.description)
27
+ parser.add_argument('-id', '--testRunUuid', help="The UUID of the test run to finish, required for finish",
28
+ default=None)
29
+
30
+ args = parser.parse_args()
31
+
32
+ config.endpoint = args.endpoint
33
+ config.token = args.accessToken
34
+ config.project = args.project
35
+ config.test_set = args.testset
36
+ config.description = args.description
37
+
38
+ client = OrangebeardClient(orangebeard_config=config)
39
+
40
+ if args.cmd == "start":
41
+ temp_uuid = client.start_test_run(StartTestRun(config.testset, datetime.now(tz), config.description), True)
42
+ asyncio.gather(client.call_events[temp_uuid].wait())
43
+ print(client.uuid_mapping[temp_uuid])
44
+ sys.exit(0)
45
+
46
+ else:
47
+ if args.cmd == "finish" and args.testRunUuid is not None:
48
+ client.finish_test_run(args.testRunUuid, FinishTestRun(datetime.now(tz)), True)
49
+ print('Orangebeard report Finished!')
50
+ sys.exit(0)
51
+
52
+ parser.print_help()
53
+ sys.exit(1)
54
+
55
+
56
+ if __name__ == '__main__':
57
+ main()
@@ -70,30 +70,33 @@ class OrangebeardClient:
70
70
  access_token = config.token
71
71
  project_name = config.project
72
72
 
73
+ self.__external_run_lifecycle = False
73
74
  self.__endpoint = endpoint
74
75
  self.__access_token = access_token
75
76
  self.__project_name = project_name
76
77
  self.__connection_with_orangebeard_is_valid: bool = True
78
+ self.__client = None
77
79
 
78
80
  self.__uuid_mapping = {}
79
81
  self.__call_events = {}
80
82
  self.__event_loop = asyncio.new_event_loop()
81
83
  asyncio.set_event_loop(self.__event_loop)
82
84
 
83
- self.__client = aiohttp.ClientSession(
84
- base_url=self.__endpoint,
85
- headers={
86
- "Authorization": f"Bearer {str(self.__access_token)}",
87
- "Content-Type": "application/json",
88
- },
89
- raise_for_status=True)
85
+ if orangebeard_config.testrun_uuid is not None:
86
+ print('external lifecycle!')
87
+ self.__external_run_lifecycle = True
88
+ self.__call_events[orangebeard_config.testrun_uuid] = asyncio.Event()
89
+ self.__uuid_mapping[orangebeard_config.testrun_uuid] = orangebeard_config.testrun_uuid
90
+ self.__call_events[orangebeard_config.testrun_uuid].set()
90
91
 
91
- def start_test_run(self, start_test_run: StartTestRun) -> UUID:
92
+
93
+ def start_test_run(self, start_test_run: StartTestRun, direct=False) -> UUID:
92
94
  """
93
95
  Start a new test run.
94
96
 
95
97
  Args:
96
98
  start_test_run (StartTestRun): The StartTestRun object containing information about the test run.
99
+ direct: boolean indicating a standalone, direct cli call
97
100
 
98
101
  Returns:
99
102
  UUID: The UUID associated with the started test run.
@@ -103,7 +106,7 @@ class OrangebeardClient:
103
106
 
104
107
  self.__call_events[temp_uuid] = start_test_run_event
105
108
 
106
- self.__event_loop.run_until_complete(self.__exec_start_test_run(start_test_run, temp_uuid))
109
+ self.__event_loop.run_until_complete(self.__exec_start_test_run(start_test_run, temp_uuid, direct))
107
110
  return temp_uuid
108
111
 
109
112
  def start_announced_test_run(self, test_run_uuid: UUID) -> None:
@@ -117,7 +120,7 @@ class OrangebeardClient:
117
120
  self.__call_events[test_run_uuid] = start_test_run_event
118
121
  self.__event_loop.run_until_complete(self.__exec_start_announced_test_run(test_run_uuid))
119
122
 
120
- def finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
123
+ def finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun, direct=False) -> None:
121
124
  """
122
125
  Wait for all events to finish and then finish the test run.
123
126
 
@@ -125,9 +128,10 @@ class OrangebeardClient:
125
128
  test_run_uuid (UUID): The UUID of the test run to be finished.
126
129
  finish_test_run (FinishTestRun): The FinishTestRun object containing information about finishing the
127
130
  test run.
131
+ direct (Bool): indication that a standalone finish call is required. True for CLI
128
132
  """
129
133
  self.__event_loop.run_until_complete(
130
- self.__exec_finish_test_run(test_run_uuid, finish_test_run))
134
+ self.__exec_finish_test_run(test_run_uuid, finish_test_run, direct))
131
135
 
132
136
  def start_suite(self, start_suite: StartSuite) -> list[UUID]:
133
137
  """
@@ -260,7 +264,19 @@ class OrangebeardClient:
260
264
  asyncio.ensure_future(self.__exec_send_attachment(attachment, temp_uuid, parent_event))
261
265
  return temp_uuid
262
266
 
267
+ async def __ensure_client(self):
268
+ if self.__client is None or self.__client.closed:
269
+ self.__client = aiohttp.ClientSession(
270
+ base_url=self.__endpoint,
271
+ headers={
272
+ "Authorization": f"Bearer {str(self.__access_token)}",
273
+ "Content-Type": "application/json",
274
+ },
275
+ raise_for_status=True
276
+ )
277
+
263
278
  async def __make_api_request(self, method: str, uri: str, data: Serializable = None, retry_count: int = 4):
279
+ await self.__ensure_client()
264
280
  for attempt in range(retry_count):
265
281
  if self.__connection_with_orangebeard_is_valid:
266
282
  try:
@@ -278,7 +294,7 @@ class OrangebeardClient:
278
294
  self.__connection_with_orangebeard_is_valid = False
279
295
  raise ConnectionError(f'Failed to communicate with Orangebeard after {retry_count} attempts')
280
296
 
281
- async def __exec_start_test_run(self, start_test_run: StartTestRun, temp_uuid: UUID) -> None:
297
+ async def __exec_start_test_run(self, start_test_run: StartTestRun, temp_uuid: UUID, direct=False) -> None:
282
298
  response = await self.__make_api_request(
283
299
  'POST',
284
300
  f'/listener/v3/{self.__project_name}/test-run/start',
@@ -288,6 +304,9 @@ class OrangebeardClient:
288
304
  self.__uuid_mapping[temp_uuid] = actual_uuid
289
305
  self.__call_events[temp_uuid].set()
290
306
 
307
+ if direct is True:
308
+ await self.__client.close()
309
+
291
310
  async def __exec_start_announced_test_run(self, test_run_uuid: UUID) -> None:
292
311
  await self.__make_api_request(
293
312
  'PUT',
@@ -296,19 +315,27 @@ class OrangebeardClient:
296
315
  self.__uuid_mapping[test_run_uuid] = test_run_uuid
297
316
  self.__call_events[test_run_uuid].set()
298
317
 
299
- async def __exec_finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
318
+ async def __exec_finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun, direct=False) -> None:
300
319
  print(f'Waiting for {len(self.__call_events.values()) + 1} Orangebeard events to finish...')
301
320
 
302
321
  for event in self.__call_events.values():
303
322
  await event.wait()
304
323
 
305
- real_test_run_uuid = self.__uuid_mapping[test_run_uuid]
306
- await self.__make_api_request(
307
- 'PUT',
308
- f'/listener/v3/{self.__project_name}/test-run/finish/{real_test_run_uuid}',
309
- finish_test_run
310
- )
311
- print('Done. Test run finished!')
324
+ if direct is True:
325
+ real_test_run_uuid = test_run_uuid
326
+ else:
327
+ real_test_run_uuid = self.__uuid_mapping[test_run_uuid]
328
+
329
+ if self.__external_run_lifecycle is False:
330
+ await self.__make_api_request(
331
+ 'PUT',
332
+ f'/listener/v3/{self.__project_name}/test-run/finish/{real_test_run_uuid}',
333
+ finish_test_run
334
+ )
335
+ print('Done. Test run finished!')
336
+ else:
337
+ print('Ended run without sending test run finish call. Remember to finish using CLI!')
338
+
312
339
  await self.__client.close()
313
340
 
314
341
  async def __exec_start_suite(self, start_suite: StartSuite, suite_temp_ids: list[UUID],
@@ -435,6 +462,7 @@ class OrangebeardClient:
435
462
  }
436
463
 
437
464
  uri = f'/listener/v3/{self.__project_name}/attachment'
465
+ await self.__ensure_client()
438
466
 
439
467
  async with self.__client.request('POST', uri, data=multipart_message, headers=headers) as response:
440
468
  if 200 <= response.status < 300:
@@ -445,3 +473,11 @@ class OrangebeardClient:
445
473
  else:
446
474
  self.__connection_with_orangebeard_is_valid = False
447
475
  raise ConnectionError(f'Failed to communicate with Orangebeard: {await response.text()}')
476
+
477
+ @property
478
+ def call_events(self):
479
+ return self.__call_events
480
+
481
+ @property
482
+ def uuid_mapping(self):
483
+ return self.__uuid_mapping
@@ -21,6 +21,7 @@ def update_config_parameters_from_env(current_config: OrangebeardParameters) ->
21
21
  os.environ.get('ORANGEBEARD_ATTRIBUTES', '')) if os.environ.get(
22
22
  'ORANGEBEARD_ATTRIBUTES') else current_config.attributes
23
23
  current_config.ref_url = os.environ.get('ORANGEBEARD_REF_URL', current_config.ref_url)
24
+ current_config.testrun_uuid = os.environ.get('ORANGEBEARD_TESTRUN_UUID', current_config.testrun_uuid)
24
25
 
25
26
  return current_config
26
27
 
@@ -9,7 +9,8 @@ class OrangebeardParameters(Serializable):
9
9
  project=None,
10
10
  description=None,
11
11
  attributes=None,
12
- ref_url=None
12
+ ref_url=None,
13
+ testrun_uuid=None
13
14
  ):
14
15
  self.token = token
15
16
  self.endpoint = endpoint
@@ -18,3 +19,4 @@ class OrangebeardParameters(Serializable):
18
19
  self.description = description
19
20
  self.attributes = attributes
20
21
  self.ref_url = ref_url
22
+ self.testrun_uuid = testrun_uuid
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: orangebeard-client
3
- Version: 2.1.1
3
+ Version: 2.3.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
@@ -1,5 +1,6 @@
1
1
  LICENSE
2
2
  pyproject.toml
3
+ orangebeard/Cli.py
3
4
  orangebeard/OrangebeardClient.py
4
5
  orangebeard/__init__.py
5
6
  orangebeard/config/AutoConfig.py
@@ -25,5 +26,6 @@ orangebeard/entity/__init__.py
25
26
  orangebeard_client.egg-info/PKG-INFO
26
27
  orangebeard_client.egg-info/SOURCES.txt
27
28
  orangebeard_client.egg-info/dependency_links.txt
29
+ orangebeard_client.egg-info/entry_points.txt
28
30
  orangebeard_client.egg-info/requires.txt
29
31
  orangebeard_client.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ orangebeard-cli = orangebeard.Cli:main
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "orangebeard-client"
7
- version = "2.1.1"
7
+ version = "2.3.0"
8
8
  description = "A python3 client for Orangebeard"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -14,6 +14,9 @@ dependencies = [ "pytz", "aiohttp",]
14
14
  name = "Tom Heintzberger"
15
15
  email = "tom@orangebeard.io"
16
16
 
17
+ [project.scripts]
18
+ orangebeard-cli = "orangebeard.Cli:main"
19
+
17
20
  [project.urls]
18
21
  Homepage = "https://github.com/orangebeard-io/python-client"
19
22
  "Bug Tracker" = "https://github.com/orangebeard-io/python-client/issues"