Index: third_party/grpc/src/python/grpcio/tests/unit/beta/_not_found_test.py |
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/server_base_unittest.py b/third_party/grpc/src/python/grpcio/tests/unit/beta/_not_found_test.py |
similarity index 50% |
copy from third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/server_base_unittest.py |
copy to third_party/grpc/src/python/grpcio/tests/unit/beta/_not_found_test.py |
index aec61f3d69db538e503b78529c63ffeb3f5e184f..44fcd1e13c24177cc12ad62fc4b082b217937112 100644 |
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/server_base_unittest.py |
+++ b/third_party/grpc/src/python/grpcio/tests/unit/beta/_not_found_test.py |
@@ -1,4 +1,5 @@ |
-# Copyright (C) 2012 Google Inc. All rights reserved. |
+# Copyright 2015, Google Inc. |
+# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions are |
@@ -26,34 +27,49 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+"""Tests of RPC-method-not-found behavior.""" |
+ |
import unittest |
-from webkitpy.common.host_mock import MockHost |
-from webkitpy.layout_tests.port import test |
-from webkitpy.layout_tests.servers.server_base import ServerBase |
+from grpc.beta import implementations |
+from grpc.beta import interfaces |
+from grpc.framework.interfaces.face import face |
+from tests.unit.framework.common import test_constants |
+ |
+class NotFoundTest(unittest.TestCase): |
-class TestServerBase(unittest.TestCase): |
+ def setUp(self): |
+ self._server = implementations.server({}) |
+ port = self._server.add_insecure_port('[::]:0') |
+ channel = implementations.insecure_channel('localhost', port) |
+ self._generic_stub = implementations.generic_stub(channel) |
+ self._server.start() |
- def test_corrupt_pid_file(self): |
- # This tests that if the pid file is corrupt or invalid, |
- # both start() and stop() deal with it correctly and delete the file. |
- host = MockHost() |
- test_port = test.TestPort(host) |
+ def tearDown(self): |
+ self._server.stop(0).wait() |
+ self._generic_stub = None |
- server = ServerBase(test_port, test_port.default_results_directory()) |
- server._pid_file = '/tmp/pidfile' |
- server._spawn_process = lambda: 4 |
- server._is_server_running_on_all_ports = lambda: True |
+ def test_blocking_unary_unary_not_found(self): |
+ with self.assertRaises(face.LocalError) as exception_assertion_context: |
+ self._generic_stub.blocking_unary_unary( |
+ 'groop', 'meffod', b'abc', test_constants.LONG_TIMEOUT, |
+ with_call=True) |
+ self.assertIs( |
+ exception_assertion_context.exception.code, |
+ interfaces.StatusCode.UNIMPLEMENTED) |
- host.filesystem.write_text_file(server._pid_file, 'foo') |
- server.stop() |
- self.assertEqual(host.filesystem.files[server._pid_file], None) |
+ def test_future_stream_unary_not_found(self): |
+ rpc_future = self._generic_stub.future_stream_unary( |
+ 'grupe', 'mevvod', b'def', test_constants.LONG_TIMEOUT) |
+ with self.assertRaises(face.LocalError) as exception_assertion_context: |
+ rpc_future.result() |
+ self.assertIs( |
+ exception_assertion_context.exception.code, |
+ interfaces.StatusCode.UNIMPLEMENTED) |
+ self.assertIs( |
+ rpc_future.exception().code, interfaces.StatusCode.UNIMPLEMENTED) |
- host.filesystem.write_text_file(server._pid_file, 'foo') |
- server.start() |
- self.assertEqual(server._pid, 4) |
- # Note that the pid file would not be None if _spawn_process() |
- # was actually a real implementation. |
- self.assertEqual(host.filesystem.files[server._pid_file], None) |
+if __name__ == '__main__': |
+ unittest.main(verbosity=2) |