Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
e8564291
Commit
e8564291
authored
Jul 18, 2008
by
temporal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Python service CallMethod() implementation.
Patch from Johan Euphrosine <proppy@aminche.com>
parent
e773b432
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
service_reflection_test.py
python/google/protobuf/internal/service_reflection_test.py
+18
-0
service_reflection.py
python/google/protobuf/service_reflection.py
+2
-2
No files found.
python/google/protobuf/internal/service_reflection_test.py
View file @
e8564291
...
...
@@ -64,6 +64,24 @@ class FooUnitTest(unittest.TestCase):
self
.
assertEqual
(
'Method Bar not implemented.'
,
rpc_controller
.
failure_message
)
self
.
assertEqual
(
None
,
self
.
callback_response
)
class
MyServiceImpl
(
unittest_pb2
.
TestService
):
def
Foo
(
self
,
rpc_controller
,
request
,
done
):
self
.
foo_called
=
True
def
Bar
(
self
,
rpc_controller
,
request
,
done
):
self
.
bar_called
=
True
srvc
=
MyServiceImpl
()
rpc_controller
.
failure_message
=
None
srvc
.
Foo
(
rpc_controller
,
unittest_pb2
.
FooRequest
(),
MyCallback
)
self
.
assertEqual
(
None
,
rpc_controller
.
failure_message
)
self
.
assertEqual
(
True
,
srvc
.
foo_called
)
rpc_controller
.
failure_message
=
None
srvc
.
CallMethod
(
service_descriptor
.
methods
[
1
],
rpc_controller
,
unittest_pb2
.
BarRequest
(),
MyCallback
)
self
.
assertEqual
(
None
,
rpc_controller
.
failure_message
)
self
.
assertEqual
(
True
,
srvc
.
bar_called
)
def
testServiceStub
(
self
):
class
MockRpcChannel
(
service
.
RpcChannel
):
...
...
python/google/protobuf/service_reflection.py
View file @
e8564291
...
...
@@ -160,8 +160,8 @@ class _ServiceBuilder(object):
if
method_descriptor
.
containing_service
!=
self
.
descriptor
:
raise
RuntimeError
(
'CallMethod() given method descriptor for wrong service type.'
)
method
=
getattr
(
s
elf
.
cls
,
method_descriptor
.
name
)
method
(
srvc
,
rpc_controller
,
request
,
callback
)
method
=
getattr
(
s
rvc
,
method_descriptor
.
name
)
method
(
rpc_controller
,
request
,
callback
)
def
_GetRequestClass
(
self
,
method_descriptor
):
"""Returns the class of the request protocol message.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment