def testMockCall(self): """Test mock call does not execute any logic.""" patch = self.PatchObject(cros_build_lib, 'run') request = self._GetInput() response = self._Output() # VmTest does not return a value, checking mocked value is flagged by lint. test_controller.VmTest(request, response, self.mock_call_config) patch.assert_not_called()
def testVmTest(self): """Call VmTest with valid args and temp dir.""" request = self._GetInput() response = self._Output() patch = self.PatchObject( cros_build_lib, 'run', return_value=cros_build_lib.CommandResult(returncode=0)) test_controller.VmTest(request, response, self.api_config) patch.assert_called()
def testTastAllOptions(self): """Test VmTest for Tast with all options set.""" test_controller.VmTest(self._GetInput(), None, self.api_config) self.assertCommandContains([ 'cros_run_test', '--debug', '--no-display', '--copy-on-write', '--board', 'target', '--image-path', '/path/to/image.bin', '--tast', 'suite', '--ssh-port', '1234', '--private-key', '/path/to/id_rsa', ])
def testAutotestAllOptions(self): """Test VmTest for Autotest with all options set.""" input_proto = self._GetInput( test_harness=test_pb2.VmTestRequest.AUTOTEST) test_controller.VmTest(input_proto, None, self.api_config) self.assertCommandContains([ 'cros_run_test', '--debug', '--no-display', '--copy-on-write', '--board', 'target', '--image-path', '/path/to/image.bin', '--autotest', 'suite', '--ssh-port', '1234', '--private-key', '/path/to/id_rsa', '--test_that-args=--whitelist-chrome-crashes', ])
def testMissingVmTests(self): """Test VmTest dies when vm_tests not set.""" input_proto = self._GetInput(vm_tests=[]) with self.assertRaises(cros_build_lib.DieSystemExit): test_controller.VmTest(input_proto, None, self.api_config)
def testMissingTestHarness(self): """Test VmTest dies when test_harness not specified.""" input_proto = self._GetInput( test_harness=test_pb2.VmTestRequest.UNSPECIFIED) with self.assertRaises(cros_build_lib.DieSystemExit): test_controller.VmTest(input_proto, None, self.api_config)
def testMissingBuildTarget(self): """Test VmTest dies when build_target not set.""" input_proto = self._GetInput(build_target=None) with self.assertRaises(cros_build_lib.DieSystemExit): test_controller.VmTest(input_proto, None, self.api_config)
def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" test_controller.VmTest(self._GetInput(), None, self.validate_only_config) self.assertEqual(0, self.rc.call_count)