def testArgumentValidation(self):
        """Test the input argument validation."""
        # Error when no build target provided.
        in_proto = self._InputProto()
        out_proto = self._OutputProto()
        with self.assertRaises(cros_build_lib.DieSystemExit):
            sysroot_controller.CreateSimpleChromeSysroot(
                in_proto, out_proto, self.api_config)

        # Valid when board is specified.
        patch = self.PatchObject(sysroot_service,
                                 'CreateSimpleChromeSysroot',
                                 return_value='/path/to/sysroot/tar.bz')
        in_proto = self._InputProto(build_target='board')
        out_proto = self._OutputProto()
        sysroot_controller.CreateSimpleChromeSysroot(in_proto, out_proto,
                                                     self.api_config)
        patch.assert_called_once()
    def testValidateOnly(self):
        """Sanity check that a validate only call does not execute any logic."""
        patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot')

        board = 'board'
        in_proto = self._InputProto(build_target=board, use_flags=[])
        sysroot_controller.CreateSimpleChromeSysroot(in_proto,
                                                     self._OutputProto(),
                                                     self.validate_only_config)
        patch.assert_not_called()
Example #3
0
    def testMockCall(self):
        """Sanity check that a mock call does not execute any logic."""
        patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot')

        board = 'board'
        in_proto = self._InputProto(build_target=board, use_flags=[])
        rc = sysroot_controller.CreateSimpleChromeSysroot(
            in_proto, self._OutputProto(), self.mock_call_config)
        self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
        patch.assert_not_called()