| """Reusable utility methods for working with continuous_test configs.""" |
| |
| import os |
| |
| from catatester.genfiles import continuous_tests_pb2 |
| from google.protobuf import text_format |
| |
| _ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| |
| # Path to the production continuous_tests.protoascii file. |
| PROD_CONFIG_PATH = os.path.join( |
| _ROOT_DIR, 'configs', 'prod', 'continuous_tests.protoascii') |
| # Path to the staging continuous_tests.protoascii file. |
| STAGING_CONFIG_PATH = os.path.join( |
| _ROOT_DIR, 'configs', 'staging', 'continuous_tests.protoascii') |
| # Path to the expectation file for the production config. |
| PROD_EXPECTATION_PATH = os.path.join( |
| _ROOT_DIR, 'configs', 'expectations', 'prod_continuous_tests.expected') |
| # Path to the expectation file for the staging config. |
| STAGING_EXPECTATION_PATH = os.path.join( |
| _ROOT_DIR, 'configs', 'expectations', 'staging_continuous_tests.expected') |
| |
| |
| def parse_continuous_tests_protoascii(path): |
| """Parse a continuous_tests config from protoascii into a proto message.""" |
| message = continuous_tests_pb2.ContinuousTestsConfig() |
| with open(path) as f: |
| text_format.Merge(f.read(), message) |
| return message |