Esempio n. 1
0
def Update(input_proto, output_proto, _config):
  """Update the chroot.

  Args:
    input_proto (UpdateRequest): The input proto.
    output_proto (UpdateResponse): The output proto.
    _config (api_config.ApiConfig): The API call config.
  """
  build_source = input_proto.flags.build_source
  targets = [target.name for target in input_proto.toolchain_targets]
  toolchain_changed = input_proto.flags.toolchain_changed

  args = sdk.UpdateArguments(
      build_source=build_source,
      toolchain_targets=targets,
      toolchain_changed=toolchain_changed)

  version = sdk.Update(args)

  if version:
    output_proto.version.version = version
  else:
    # This should be very rare, if ever used, but worth noting.
    cros_build_lib.Die('No chroot version could be found. There was likely an'
                       'error creating the chroot that was not detected.')
Esempio n. 2
0
    def testUpdate(self):
        """Test the update method."""
        arguments = sdk.UpdateArguments()
        expected_args = ['--arg', '--other', '--with-value', 'value']
        expected_version = 1
        self.PatchObject(arguments, 'GetArgList', return_value=expected_args)
        self.PatchObject(sdk,
                         'GetChrootVersion',
                         return_value=expected_version)

        version = sdk.Update(arguments)

        self.assertCommandContains(expected_args)
        self.assertEqual(expected_version, version)
Esempio n. 3
0
  def testArgumentHandling(self):
    """Test the proto argument handling."""
    args = sdk_service.UpdateArguments()
    self.PatchObject(sdk_service, 'Update', return_value=1)
    args_patch = self.PatchObject(sdk_service, 'UpdateArguments',
                                  return_value=args)

    # No boards and flags False.
    request = self._GetRequest(build_source=False)
    sdk_controller.Update(request, self.response, self.api_config)
    args_patch.assert_called_with(build_source=False, toolchain_targets=[])

    # Multiple boards and flags True.
    targets = ['board1', 'board2']
    request = self._GetRequest(build_source=True, targets=targets)
    sdk_controller.Update(request, self.response, self.api_config)
    args_patch.assert_called_with(build_source=True, toolchain_targets=targets)
Esempio n. 4
0
 def _GetArgList(self, **kwargs):
     """Helper to simplify getting the argument list."""
     instance = sdk.UpdateArguments(**kwargs)
     return instance.GetArgList()