BuildAPI: Use faux.empty_completed_unsuccessfully_error for tests.

BUG=chromium:1029872
TEST=run_tests

Change-Id: Id4be0f617e1a9ed1df545c2c7c2970dfbfd796cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1964694
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
Tested-by: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/image_unittest.py b/api/controller/image_unittest.py
index 6cce6c5..56de3c3 100644
--- a/api/controller/image_unittest.py
+++ b/api/controller/image_unittest.py
@@ -58,6 +58,15 @@
     patch.assert_not_called()
     self.assertEqual(self.response.success, True)
 
+  def testMockError(self):
+    """Test that mock call does not execute any logic, returns error."""
+    patch = self.PatchObject(image_service, 'Build')
+
+    request = self._GetRequest(board='board')
+    rc = image_controller.Create(request, self.response, self.mock_error_config)
+    patch.assert_not_called()
+    self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
+
   def testNoBoard(self):
     """Test no board given fails."""
     request = self._GetRequest()
@@ -171,6 +180,19 @@
     patch.assert_not_called()
     self.assertEqual(output_proto.success, True)
 
+  def testMockError(self):
+    """Test that mock call does not execute any logic, returns error."""
+    patch = self.PatchObject(image_lib, 'SecurityTest', return_value=True)
+    input_proto = image_pb2.TestImageRequest()
+    input_proto.image.path = self.image_path
+    output_proto = image_pb2.TestImageResult()
+
+    rc = image_controller.SignerTest(input_proto, output_proto,
+                                     self.mock_error_config)
+
+    patch.assert_not_called()
+    self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
+
   def testSignerTestNoImage(self):
     """Test function argument validation."""
     input_proto = image_pb2.TestImageRequest()
@@ -239,6 +261,21 @@
     patch.assert_not_called()
     self.assertEqual(output_proto.success, True)
 
+  def testMockError(self):
+    """Test that mock call does not execute any logic, returns error."""
+    patch = self.PatchObject(image_service, 'Test')
+
+    input_proto = image_pb2.TestImageRequest()
+    input_proto.image.path = self.image_path
+    input_proto.build_target.name = self.board
+    input_proto.result.directory = self.result_directory
+    output_proto = image_pb2.TestImageResult()
+
+    rc = image_controller.Test(input_proto, output_proto,
+                               self.mock_error_config)
+    patch.assert_not_called()
+    self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
+
   def testTestArgumentValidation(self):
     """Test function argument validation tests."""
     self.PatchObject(image_service, 'Test', return_value=True)