• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / openhtf / 15172355628

21 May 2025 08:52PM UTC coverage: 62.277% (+0.02%) from 62.254%
15172355628

push

github

copybara-github
Merge pull request #1230 from glados-verma:feat-test-measurements-and-helper

PiperOrigin-RevId: 761656356

8 of 10 new or added lines in 1 file covered. (80.0%)

4687 of 7526 relevant lines covered (62.28%)

3.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/openhtf/util/example_test.py
1
# Copyright 2016 Google Inc. All Rights Reserved.
2

3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6

7
#     http://www.apache.org/licenses/LICENSE-2.0
8

9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
"""Utilities for integration testing OpenHTF examples."""
15

16
from typing import Any
5✔
17
import unittest
5✔
18

19

20
class ExampleTestBase(unittest.TestCase):
5✔
21
  """Base class for integration testing OpenHTF examples."""
22

23
  def get_phase_by_name(
5✔
24
      self, json_data: dict[str, Any], phase_name: str
25
  ) -> dict[str, Any]:
26
    """Finds a phase by its name in a test output JSON.
27

28
    Args:
29
      json_data: The JSON data as loaded from the output file, generated by the
30
        default JSON output callback.
31
      phase_name: The name of the phase to find.
32

33
    Returns:
34
      The phase dictionary if found.
35

36
    Raises:
37
      AssertionError (via test_case.fail()): If the phase is not found
38
        or json_data does not have the expected "phases" key.
39
    """
40
    if "phases" not in json_data:
5✔
NEW
41
      self.fail("JSON data does not contain 'phases' key.")
×
42
    for p in json_data["phases"]:
5✔
43
      if p["name"] == phase_name:
5✔
44
        return p
5✔
NEW
45
    self.fail(f"Phase '{phase_name}' not found in output.")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc