blob: e9259d33dee9612a2afec283dda0a045664b6956 [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from google.protobuf import text_format as textpb
from recipe_engine import recipe_test_api
class TextProtoTestApi(recipe_test_api.RecipeTestApi):
def spec_not_found(self, step_name='build_init'):
"""
Returns mock step data that simulates a missing spec file.
"""
return self.step_data(step_name, retcode=2)
def spec_parse_error(self, step_name='build_init'):
"""
Returns mock step data that simulates a spec file that fails to parse.
"""
return self.step_data(
step_name,
stdout=self.m.raw_io.output('not a proto message'),
retcode=0,
)
def spec_loaded_ok(self, message, step_name='build_init'):
"""
Returns mock step data that simulates successfully fetching a spec file.
Args:
message: The spec as a protobuf Message.
"""
return self.step_data(
step_name,
retcode=0,
stdout=self.m.raw_io.output(textpb.MessageToString(message)),
)