BuildAPI: Add remaining testMockCall tests for Test service.
BUG=chromium:1029033
TEST=run_tests
Change-Id: Ie4b321344e5676766ce1aad7119d5b8808094c5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1965684
Tested-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/test_unittest.py b/api/controller/test_unittest.py
index 5162780..156a3d2 100644
--- a/api/controller/test_unittest.py
+++ b/api/controller/test_unittest.py
@@ -326,6 +326,12 @@
test_controller.CrosSigningTest(None, None, self.validate_only_config)
self.assertFalse(self.rc.call_count)
+ def testMockCall(self):
+ """Test mock call does not execute any logic, returns success."""
+ rc = test_controller.CrosSigningTest(None, None, self.mock_call_config)
+ self.assertFalse(self.rc.call_count)
+ self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
+
def testCrosSigningTest(self):
"""Call CrosSigningTest with mocked cros_build_lib.run."""
request = self._GetInput(chroot_path=self.chroot_path)
@@ -406,6 +412,18 @@
self.validate_only_config)
self.mock_simple_chrome_workflow_test.assert_not_called()
+ def testMockCall(self):
+ """Test mock call does not execute any logic, returns success."""
+ patch = self.mock_simple_chrome_workflow_test = self.PatchObject(
+ test_service, 'SimpleChromeWorkflowTest')
+
+ request = self._Input(sysroot_path='sysroot_path', build_target='board',
+ chrome_root='/path/to/chrome')
+ rc = test_controller.SimpleChromeWorkflowTest(request, self._Output(),
+ self.mock_call_config)
+ patch.assert_not_called()
+ self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
+
class VmTestTest(cros_test_lib.RunCommandTestCase, api_config.ApiConfigMixin):
"""Test the VmTest endpoint."""
@@ -432,6 +450,16 @@
test_controller.VmTest(self._GetInput(), None, self.validate_only_config)
self.assertEqual(0, self.rc.call_count)
+ 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 testTastAllOptions(self):
"""Test VmTest for Tast with all options set."""
test_controller.VmTest(self._GetInput(), None, self.api_config)
@@ -548,6 +576,16 @@
self.validate_only_config)
self.mock_create_moblab_vms.assert_not_called()
+ def testMockCall(self):
+ """Test mock call does not execute any logic."""
+ patch = self.PatchObject(key_value_store, 'LoadFile')
+
+ # MoblabVmTest does not return a value, checking mocked value is flagged by
+ # lint.
+ test_controller.MoblabVmTest(self._Input(), self._Output(),
+ self.mock_call_config)
+ patch.assert_not_called()
+
def testImageContainsBuilder(self):
"""MoblabVmTest calls service with correct args."""
request = self._Input()