def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" patch = self.PatchObject(binhost_service, 'SetBinhost') request = binhost_pb2.SetBinhostRequest() request.build_target.name = 'target' request.key = binhost_pb2.POSTSUBMIT_BINHOST request.uri = 'gs://chromeos-prebuilt/target' binhost.SetBinhost(request, self.response, self.validate_only_config) patch.assert_not_called()
def testMockCall(self): """Test that a mock call does not execute logic, returns mocked value.""" patch = self.PatchObject(binhost_service, 'SetBinhost') request = binhost_pb2.SetBinhostRequest() request.build_target.name = 'target' request.key = binhost_pb2.POSTSUBMIT_BINHOST request.uri = 'gs://chromeos-prebuilt/target' binhost.SetBinhost(request, self.response, self.mock_call_config) patch.assert_not_called() self.assertEqual(self.response.output_file, '/path/to/BINHOST.conf')
def testSetBinhost(self): """SetBinhost calls service with correct args.""" set_binhost = self.PatchObject(binhost_service, 'SetBinhost', return_value='/path/to/BINHOST.conf') input_proto = binhost_pb2.SetBinhostRequest() input_proto.build_target.name = 'target' input_proto.private = True input_proto.key = binhost_pb2.POSTSUBMIT_BINHOST input_proto.uri = 'gs://chromeos-prebuilt/target' binhost.SetBinhost(input_proto, self.response, self.api_config) self.assertEqual(self.response.output_file, '/path/to/BINHOST.conf') set_binhost.assert_called_once_with('target', 'POSTSUBMIT_BINHOST', 'gs://chromeos-prebuilt/target', private=True)