def _GetFailureTestRefs(test_summary):
  """Gets a list of test summaryRef id of all failure test.

  Args:
    test_summary: dict, a dict of test summary object.
  Returns:
    A list of failure test case's summaryRef id.
  """
  failure_test_refs = []
  if 'subtests' in test_summary:
    for sub_test_summary in test_summary['subtests']['_values']:
      failure_test_refs.extend(_GetFailureTestRefs(sub_test_summary))
  else:
    if (('testStatus' not in test_summary or
         test_summary['testStatus']['_value'] != 'Success') and
        'summaryRef' in test_summary):
      summary_ref_id = test_summary['summaryRef']['id']['_value']
      failure_test_refs.append(summary_ref_id)
  return failure_test_refs