orangebeard-client 2.2.0__tar.gz → 2.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.
Files changed (33) hide show
  1. {orangebeard_client-2.2.0/orangebeard_client.egg-info → orangebeard_client-2.4.0}/PKG-INFO +1 -1
  2. orangebeard_client-2.4.0/orangebeard/Cli.py +57 -0
  3. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/OrangebeardClient.py +63 -22
  4. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/config/AutoConfig.py +1 -0
  5. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/OrangebeardParameters.py +3 -1
  6. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0/orangebeard_client.egg-info}/PKG-INFO +1 -1
  7. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard_client.egg-info/SOURCES.txt +2 -0
  8. orangebeard_client-2.4.0/orangebeard_client.egg-info/entry_points.txt +2 -0
  9. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/pyproject.toml +4 -1
  10. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/LICENSE +0 -0
  11. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/__init__.py +0 -0
  12. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/Attachment.py +0 -0
  13. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/Attribute.py +0 -0
  14. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/FinishStep.py +0 -0
  15. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/FinishTest.py +0 -0
  16. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/FinishTestRun.py +0 -0
  17. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/Log.py +0 -0
  18. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/LogFormat.py +0 -0
  19. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/LogLevel.py +0 -0
  20. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/SUTComponent.py +0 -0
  21. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/Serializable.py +0 -0
  22. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/StartStep.py +0 -0
  23. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/StartSuite.py +0 -0
  24. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/StartTest.py +0 -0
  25. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/StartTestRun.py +0 -0
  26. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/Suite.py +0 -0
  27. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/TestStatus.py +0 -0
  28. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/TestType.py +0 -0
  29. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard/entity/__init__.py +0 -0
  30. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard_client.egg-info/dependency_links.txt +0 -0
  31. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard_client.egg-info/requires.txt +0 -0
  32. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/orangebeard_client.egg-info/top_level.txt +0 -0
  33. {orangebeard_client-2.2.0 → orangebeard_client-2.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: orangebeard-client
3
- Version: 2.2.0
3
+ Version: 2.4.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.testset = 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,6 +70,7 @@ 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
@@ -81,14 +82,20 @@ class OrangebeardClient:
81
82
  self.__event_loop = asyncio.new_event_loop()
82
83
  asyncio.set_event_loop(self.__event_loop)
83
84
 
85
+ if orangebeard_config.testrun_uuid is not None:
86
+ self.__external_run_lifecycle = True
87
+ self.__call_events[orangebeard_config.testrun_uuid] = asyncio.Event()
88
+ self.__uuid_mapping[orangebeard_config.testrun_uuid] = orangebeard_config.testrun_uuid
89
+ self.__call_events[orangebeard_config.testrun_uuid].set()
84
90
 
85
91
 
86
- def start_test_run(self, start_test_run: StartTestRun) -> UUID:
92
+ def start_test_run(self, start_test_run: StartTestRun, direct=False) -> UUID:
87
93
  """
88
94
  Start a new test run.
89
95
 
90
96
  Args:
91
97
  start_test_run (StartTestRun): The StartTestRun object containing information about the test run.
98
+ direct: boolean indicating a standalone, direct cli call
92
99
 
93
100
  Returns:
94
101
  UUID: The UUID associated with the started test run.
@@ -98,7 +105,7 @@ class OrangebeardClient:
98
105
 
99
106
  self.__call_events[temp_uuid] = start_test_run_event
100
107
 
101
- self.__event_loop.run_until_complete(self.__exec_start_test_run(start_test_run, temp_uuid))
108
+ self.__event_loop.run_until_complete(self.__exec_start_test_run(start_test_run, temp_uuid, direct))
102
109
  return temp_uuid
103
110
 
104
111
  def start_announced_test_run(self, test_run_uuid: UUID) -> None:
@@ -112,7 +119,7 @@ class OrangebeardClient:
112
119
  self.__call_events[test_run_uuid] = start_test_run_event
113
120
  self.__event_loop.run_until_complete(self.__exec_start_announced_test_run(test_run_uuid))
114
121
 
115
- def finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
122
+ def finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun, direct=False) -> None:
116
123
  """
117
124
  Wait for all events to finish and then finish the test run.
118
125
 
@@ -120,9 +127,10 @@ class OrangebeardClient:
120
127
  test_run_uuid (UUID): The UUID of the test run to be finished.
121
128
  finish_test_run (FinishTestRun): The FinishTestRun object containing information about finishing the
122
129
  test run.
130
+ direct (Bool): indication that a standalone finish call is required. True for CLI
123
131
  """
124
132
  self.__event_loop.run_until_complete(
125
- self.__exec_finish_test_run(test_run_uuid, finish_test_run))
133
+ self.__exec_finish_test_run(test_run_uuid, finish_test_run, direct))
126
134
 
127
135
  def start_suite(self, start_suite: StartSuite) -> list[UUID]:
128
136
  """
@@ -285,7 +293,7 @@ class OrangebeardClient:
285
293
  self.__connection_with_orangebeard_is_valid = False
286
294
  raise ConnectionError(f'Failed to communicate with Orangebeard after {retry_count} attempts')
287
295
 
288
- async def __exec_start_test_run(self, start_test_run: StartTestRun, temp_uuid: UUID) -> None:
296
+ async def __exec_start_test_run(self, start_test_run: StartTestRun, temp_uuid: UUID, direct=False) -> None:
289
297
  response = await self.__make_api_request(
290
298
  'POST',
291
299
  f'/listener/v3/{self.__project_name}/test-run/start',
@@ -295,6 +303,9 @@ class OrangebeardClient:
295
303
  self.__uuid_mapping[temp_uuid] = actual_uuid
296
304
  self.__call_events[temp_uuid].set()
297
305
 
306
+ if direct is True:
307
+ await self.__client.close()
308
+
298
309
  async def __exec_start_announced_test_run(self, test_run_uuid: UUID) -> None:
299
310
  await self.__make_api_request(
300
311
  'PUT',
@@ -303,19 +314,27 @@ class OrangebeardClient:
303
314
  self.__uuid_mapping[test_run_uuid] = test_run_uuid
304
315
  self.__call_events[test_run_uuid].set()
305
316
 
306
- async def __exec_finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun) -> None:
317
+ async def __exec_finish_test_run(self, test_run_uuid: UUID, finish_test_run: FinishTestRun, direct=False) -> None:
307
318
  print(f'Waiting for {len(self.__call_events.values()) + 1} Orangebeard events to finish...')
308
319
 
309
320
  for event in self.__call_events.values():
310
321
  await event.wait()
311
322
 
312
- real_test_run_uuid = self.__uuid_mapping[test_run_uuid]
313
- await self.__make_api_request(
314
- 'PUT',
315
- f'/listener/v3/{self.__project_name}/test-run/finish/{real_test_run_uuid}',
316
- finish_test_run
317
- )
318
- print('Done. Test run finished!')
323
+ if direct is True:
324
+ real_test_run_uuid = test_run_uuid
325
+ else:
326
+ real_test_run_uuid = self.__uuid_mapping[test_run_uuid]
327
+
328
+ if self.__external_run_lifecycle is False:
329
+ await self.__make_api_request(
330
+ 'PUT',
331
+ f'/listener/v3/{self.__project_name}/test-run/finish/{real_test_run_uuid}',
332
+ finish_test_run
333
+ )
334
+ print('Done. Test run finished!')
335
+ else:
336
+ print('Done. Remember to finish run using CLI!')
337
+
319
338
  await self.__client.close()
320
339
 
321
340
  async def __exec_start_suite(self, start_suite: StartSuite, suite_temp_ids: list[UUID],
@@ -442,14 +461,36 @@ class OrangebeardClient:
442
461
  }
443
462
 
444
463
  uri = f'/listener/v3/{self.__project_name}/attachment'
464
+ retry_count = 4
445
465
  await self.__ensure_client()
446
-
447
- async with self.__client.request('POST', uri, data=multipart_message, headers=headers) as response:
448
- if 200 <= response.status < 300:
449
- response_text = await response.text()
450
- actual_uuid = response_text if response_text else None
451
- self.__uuid_mapping[temp_uuid] = actual_uuid
452
- self.__call_events[temp_uuid].set()
466
+ for attempt in range(retry_count):
467
+ if self.__connection_with_orangebeard_is_valid:
468
+ try:
469
+ async with self.__client.request('POST', uri, data=multipart_message,
470
+ headers=headers) as response:
471
+ try:
472
+ if 200 <= response.status < 300:
473
+ response_text = await response.text()
474
+ actual_uuid = response_text if response_text else None
475
+ self.__uuid_mapping[temp_uuid] = actual_uuid
476
+ self.__call_events[temp_uuid].set()
477
+ return response_text
478
+ except ContentTypeError:
479
+ return None
480
+ except ClientError:
481
+ await asyncio.sleep(2 ** (attempt + 1))
453
482
  else:
454
- self.__connection_with_orangebeard_is_valid = False
455
- raise ConnectionError(f'Failed to communicate with Orangebeard: {await response.text()}')
483
+ break
484
+
485
+ else:
486
+ self.__connection_with_orangebeard_is_valid = False
487
+ raise ConnectionError(f'Failed to communicate with Orangebeard after {retry_count} attempts')
488
+
489
+
490
+ @property
491
+ def call_events(self):
492
+ return self.__call_events
493
+
494
+ @property
495
+ def uuid_mapping(self):
496
+ 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.2.0
3
+ Version: 2.4.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.2.0"
7
+ version = "2.4.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"