Build API: Simplify the input/output message handling.
Remove the empty input/output logic until. Currently no use for it
and it resulted in confusing errors and unnecessary edge cases.
It can be reintroduced if needed, but for now, this simplification
is nicer.
BUG=None
TEST=manual
Change-Id: I4b3443af3a8334c026db3e6b22f8500951885de1
Reviewed-on: https://chromium-review.googlesource.com/1461268
Commit-Ready: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Alec Thilenius <athilenius@google.com>
diff --git a/api/build_api_unittest.py b/api/build_api_unittest.py
index 6492ae9..8821e25 100644
--- a/api/build_api_unittest.py
+++ b/api/build_api_unittest.py
@@ -32,67 +32,11 @@
self.router.Route('chromite.api.TestApiService', 'InputOutputMethod',
self._INPUT_JSON)
- # Implementation expecting two methods with definitions that have Empty
- # for the input, output, and both messages.
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'InputMethod',
- self._INPUT_JSON)
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'OutputMethod',
- self._INPUT_JSON)
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'NoIoMethod',
- self._INPUT_JSON)
-
- def testInputMethod(self):
- """Test methods with only an input message."""
- def impl(input_msg):
- self.assertIsInstance(input_msg, build_api_test_pb2.TestRequestMessage)
-
- self.PatchObject(self.router, '_GetMethod', return_value=impl)
-
- self.router.Route('chromite.api.TestApiService', 'InputMethod',
- self._INPUT_JSON)
-
- # Test errors raised for implementations expecting input message with
- # definitions that expect both messages, output only, and neither.
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'InputOutputMethod',
- self._INPUT_JSON)
- with self.assertRaises(AssertionError):
- self.router.Route('chromite.api.TestApiService', 'OutputMethod',
- self._INPUT_JSON)
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'NoIoMethod',
- self._INPUT_JSON)
-
- def testOutputMethod(self):
- """Test methods with only an output message."""
- def impl(output_msg):
- self.assertIsInstance(output_msg, build_api_test_pb2.TestResultMessage)
-
- self.PatchObject(self.router, '_GetMethod', return_value=impl)
-
- self.router.Route('chromite.api.TestApiService', 'OutputMethod',
- self._INPUT_JSON)
-
- # Test errors raised for implementations expecting input message with
- # definitions that expect both messages, output only, and neither.
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'InputOutputMethod',
- self._INPUT_JSON)
- with self.assertRaises(AssertionError):
- self.router.Route('chromite.api.TestApiService', 'InputMethod',
- self._INPUT_JSON)
- with self.assertRaises(TypeError):
- self.router.Route('chromite.api.TestApiService', 'NoIoMethod',
- self._INPUT_JSON)
-
def testRenameMethod(self):
"""Test implementation name config."""
def _GetMethod(_, method_name):
self.assertEqual('CorrectName', method_name)
- return lambda: None
+ return lambda x, y: None
self.PatchObject(self.router, '_GetMethod', side_effect=_GetMethod)
@@ -104,7 +48,7 @@
# Helper variables/functions to make the patches simpler.
should_be_called = False
is_inside = False
- def impl():
+ def impl(_input_msg, _output_msg):
self.assertTrue(should_be_called,
'The implementation should not have been called.')
def inside():
@@ -140,7 +84,7 @@
# Helper variables/functions to make the patches simpler.
should_be_called = False
is_inside = False
- def impl():
+ def impl(_input_msg, _output_msg):
self.assertTrue(should_be_called,
'The implementation should not have been called.')