opentf-toolkit-nightly 0.55.0.dev918__py3-none-any.whl → 0.55.0.dev934__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.
@@ -44,15 +44,17 @@ def in_scope(expr: str, contexts: Dict[str, Any], scopes_errors: Set[str]) -> bo
44
44
  return False
45
45
 
46
46
 
47
- def get_testresults(
48
- events: List[Dict[str, Any]]
49
- ) -> Generator[Dict[str, Any], None, None]:
47
+ def get_testresults(events: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
50
48
  """Return a possibly empty list of Notifications.
51
49
 
52
50
  Each notification in the list is guaranteed to have a
53
51
  `spec.testResults` entry.
54
52
  """
55
- return (item for item in events if _has_testresult(item))
53
+ return [item for item in events if _has_testresult(item)]
54
+
55
+
56
+ def _as_list(what) -> List[str]:
57
+ return [what] if isinstance(what, str) else what
56
58
 
57
59
 
58
60
  def _has_testresult(item: Dict[str, Any]) -> bool:
@@ -62,8 +64,44 @@ def _has_testresult(item: Dict[str, Any]) -> bool:
62
64
  )
63
65
 
64
66
 
65
- def _as_list(what) -> List[str]:
66
- return [what] if isinstance(what, str) else what
67
+ def _uses_inception(events: List[Dict[str, Any]]) -> bool:
68
+ """Determines if a workflow is the inception workflow."""
69
+ workflow_event = next(
70
+ (event for event in events if event['kind'] == 'Workflow'), None
71
+ )
72
+ if not workflow_event:
73
+ raise ValueError(
74
+ 'No Workflow event in workflow events, is there any event at all?'
75
+ )
76
+ return any(
77
+ 'inception' in _as_list(job['runs-on'])
78
+ for job in workflow_event['jobs'].values()
79
+ )
80
+
81
+
82
+ def _get_inception_testresults(events: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
83
+ """Get unique testResults notifications for inception workflow.
84
+
85
+ Note: This is a kludge until we find a reliable way to map such results
86
+ to the executed tests list.
87
+ """
88
+ unique_results = set()
89
+ unique_events = []
90
+ for event in get_testresults(events):
91
+ event_results = []
92
+ for result in event['spec']['testResults']:
93
+ event_results.append(
94
+ (
95
+ result['attachment_origin'],
96
+ result['name'],
97
+ result['duration'],
98
+ result['status'],
99
+ )
100
+ )
101
+ if tuple(event_results) not in unique_results:
102
+ unique_results.add(tuple(event_results))
103
+ unique_events.append(event)
104
+ return unique_events
67
105
 
68
106
 
69
107
  def _get_testresult_params(param_step_id: str, job: Dict[str, Any]) -> Dict[str, Any]:
@@ -229,6 +267,7 @@ def _get_timestamp(
229
267
 
230
268
  def _get_testresult_timestamps(
231
269
  events: List[Dict[str, Any]],
270
+ testresults: List[Dict[str, Any]],
232
271
  testcase_metadata: Dict[str, Any],
233
272
  ):
234
273
  """Set timestamp for each testcase in testcase_metadata.
@@ -242,7 +281,7 @@ def _get_testresult_timestamps(
242
281
  }
243
282
 
244
283
  origins_results = defaultdict(list)
245
- for item in get_testresults(events):
284
+ for item in testresults:
246
285
  for result in item['spec']['testResults']:
247
286
  origins_results[result['attachment_origin']].append(result['id'])
248
287
 
@@ -310,7 +349,12 @@ def get_testcases(events: List[Dict[str, Any]]) -> Dict[str, Dict[str, Any]]:
310
349
  """
311
350
  testcases = {}
312
351
  results = False
313
- for testresult in get_testresults(events):
352
+ if _uses_inception(events):
353
+ testresults = _get_inception_testresults(events)
354
+ else:
355
+ testresults = get_testresults(events)
356
+
357
+ for testresult in testresults:
314
358
  results = True
315
359
  labels = _get_testresult_labels(
316
360
  testresult['metadata']['attachment_origin'][0], events
@@ -318,13 +362,13 @@ def get_testcases(events: List[Dict[str, Any]]) -> Dict[str, Dict[str, Any]]:
318
362
  if not labels:
319
363
  continue
320
364
  for testcase in testresult['spec']['testResults']:
321
- labels['status'] = testcase['status']
322
365
  testcases[testcase['id']] = {
323
366
  'name': testcase['name'],
324
367
  'status': testcase['status'],
325
368
  'duration': testcase.get('duration', 0),
326
- 'test': labels,
369
+ 'test': labels.copy(),
327
370
  }
371
+ testcases[testcase['id']]['test']['status'] = testcase['status']
328
372
  data = {}
329
373
  if testcase['status'] in FAILURE_STATUSES:
330
374
  data = {key: testcase[key] for key in DETAILS_KEYS if testcase.get(key)}
@@ -333,5 +377,5 @@ def get_testcases(events: List[Dict[str, Any]]) -> Dict[str, Dict[str, Any]]:
333
377
  testcases[testcase['id']].update(data)
334
378
  if not results:
335
379
  raise ValueError('No test results in events.')
336
- _get_testresult_timestamps(events, testcases)
380
+ _get_testresult_timestamps(events, testresults, testcases)
337
381
  return testcases
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentf-toolkit-nightly
3
- Version: 0.55.0.dev918
3
+ Version: 0.55.0.dev934
4
4
  Summary: OpenTestFactory Orchestrator Toolkit
5
5
  Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
6
6
  Author: Martin Lafaix
@@ -1,7 +1,7 @@
1
1
  opentf/commons/__init__.py,sha256=ITzg1zfZgA5-4wvmJfjLN94_Z06HeMl0szd6dalrrKY,21839
2
2
  opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
3
3
  opentf/commons/config.py,sha256=GmvInVnUsXIwlNfgTQeQ_pPs97GeGTGn2S2QZEFwss8,7828
4
- opentf/commons/datasources.py,sha256=UKqlpx6_7BqZA_-FftGfIa6QaAT_aY-zCA9vtAk1-Qg,10891
4
+ opentf/commons/datasources.py,sha256=4I7i18tZOITAEW_M8_tnxILMbN9jgm3xGkFFZpjTgG8,12432
5
5
  opentf/commons/expressions.py,sha256=A68F27Our8oVVphUrRvB5haSlqj2YCrH2OxHPNLBio4,19251
6
6
  opentf/commons/pubsub.py,sha256=7khxAHVZiwJRcwIBJ6MPR-f3xY9144-2eNLROwq5F-4,5894
7
7
  opentf/commons/schemas.py,sha256=lokZCU-wmsIkzVA-TVENtC7Io_GmYxrP-FQaOOowg4s,4044
@@ -48,8 +48,8 @@ opentf/scripts/startup.py,sha256=Da2zo93pBWbdRmj-wgekgLcF94rpNc3ZkbvR8R0w8XY,212
48
48
  opentf/toolkit/__init__.py,sha256=g3DiTZlSvvzZWKgM8qU47muLqjQrpWZ6M6PWZ-sBsvQ,19610
49
49
  opentf/toolkit/channels.py,sha256=Cng3b4LUsxvCHUbp_skys9CFcKZMfcKhA_ODg_EAlIE,17156
50
50
  opentf/toolkit/core.py,sha256=L1fT4YzwZjqE7PUXhJL6jSVQge3ohBQv5UBb9DAC6oo,9320
51
- opentf_toolkit_nightly-0.55.0.dev918.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
52
- opentf_toolkit_nightly-0.55.0.dev918.dist-info/METADATA,sha256=aCdjrtZbePPqBMOUJpad8-mX2rE0-11RYU62K0Sii7M,1945
53
- opentf_toolkit_nightly-0.55.0.dev918.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
54
- opentf_toolkit_nightly-0.55.0.dev918.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
55
- opentf_toolkit_nightly-0.55.0.dev918.dist-info/RECORD,,
51
+ opentf_toolkit_nightly-0.55.0.dev934.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
52
+ opentf_toolkit_nightly-0.55.0.dev934.dist-info/METADATA,sha256=2-n3O14aeuEEXrUFFACE0bo_3Nt0p82zLsJp2Y26VN0,1945
53
+ opentf_toolkit_nightly-0.55.0.dev934.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
54
+ opentf_toolkit_nightly-0.55.0.dev934.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
55
+ opentf_toolkit_nightly-0.55.0.dev934.dist-info/RECORD,,