_not_found_test.py
Go to the documentation of this file.
1 # Copyright 2015 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Tests of RPC-method-not-found behavior."""
15 
16 import unittest
17 
18 from grpc.beta import implementations
19 from grpc.beta import interfaces
20 from grpc.framework.interfaces.face import face
21 
22 from tests.unit.framework.common import test_constants
23 
24 
25 class NotFoundTest(unittest.TestCase):
26 
27  def setUp(self):
28  self._server = implementations.server({})
29  port = self._server.add_insecure_port('[::]:0')
30  channel = implementations.insecure_channel('localhost', port)
31  self._generic_stub = implementations.generic_stub(channel)
32  self._server.start()
33 
34  def tearDown(self):
35  self._server.stop(0).wait()
36  self._generic_stub = None
37 
39  with self.assertRaises(face.LocalError) as exception_assertion_context:
40  self._generic_stub.blocking_unary_unary('groop',
41  'meffod',
42  b'abc',
43  test_constants.LONG_TIMEOUT,
44  with_call=True)
45  self.assertIs(exception_assertion_context.exception.code,
46  interfaces.StatusCode.UNIMPLEMENTED)
47 
49  rpc_future = self._generic_stub.future_stream_unary(
50  'grupe', 'mevvod', iter([b'def']), test_constants.LONG_TIMEOUT)
51  with self.assertRaises(face.LocalError) as exception_assertion_context:
52  rpc_future.result()
53  self.assertIs(exception_assertion_context.exception.code,
54  interfaces.StatusCode.UNIMPLEMENTED)
55  self.assertIs(rpc_future.exception().code,
56  interfaces.StatusCode.UNIMPLEMENTED)
57 
58 
59 if __name__ == '__main__':
60  unittest.main(verbosity=2)
grpc.framework.interfaces.face
Definition: src/python/grpcio/grpc/framework/interfaces/face/__init__.py:1
grpc.beta
Definition: src/python/grpcio/grpc/beta/__init__.py:1
tests.unit.beta._not_found_test.NotFoundTest.tearDown
def tearDown(self)
Definition: _not_found_test.py:34
start
static uint64_t start
Definition: benchmark-pound.c:74
tests.unit.beta._not_found_test.NotFoundTest.test_future_stream_unary_not_found
def test_future_stream_unary_not_found(self)
Definition: _not_found_test.py:48
tests.unit.beta._not_found_test.NotFoundTest.test_blocking_unary_unary_not_found
def test_blocking_unary_unary_not_found(self)
Definition: _not_found_test.py:38
tests.unit.beta._not_found_test.NotFoundTest.setUp
def setUp(self)
Definition: _not_found_test.py:27
tests.unit.beta._not_found_test.NotFoundTest
Definition: _not_found_test.py:25
wait
static void wait(notification *n)
Definition: alts_tsi_handshaker_test.cc:114
tests.unit.beta._not_found_test.NotFoundTest._server
_server
Definition: _not_found_test.py:28
stop
static const char stop[]
Definition: benchmark-async-pummel.c:35
iter
Definition: test_winkernel.cpp:47
tests.unit.framework.common
Definition: src/python/grpcio_tests/tests/unit/framework/common/__init__.py:1
tests.unit.beta._not_found_test.NotFoundTest._generic_stub
_generic_stub
Definition: _not_found_test.py:31


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:27