Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#167: Add Client class under Service class #222

Merged
merged 1 commit into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Nirum/Targets/Python.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,11 @@ class {className}_Client($className):
self.__nirum_transport__ = transport # type: transport_type

{clientMethods'}

{className}.Client = {className}_Client
{className}.Client.__name__ = 'Client'
if hasattr({className}.Client, '__qualname__'):
{className}.Client.__qualname__ = '{className}.Client'
|]
where
nirumMapName :: T.Text
Expand Down
14 changes: 12 additions & 2 deletions test/python/service_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import uuid

from nirum.transport import Transport
from six import PY2

from fixture.foo import (Dog, Gender, PingService, Product, RpcError,
SampleService_Client, Way)
SampleService, SampleService_Client, Way)


def test_throws_error():
Expand Down Expand Up @@ -48,7 +49,8 @@ def latest_call(self):

def test_service_client_payload_serialization():
t = DumbTransport()
c = SampleService_Client(t)
c = SampleService.Client(t)
assert SampleService_Client is SampleService.Client
c.sample_method(
a=Dog(name=u'Dog.name', age=3),
b=Product(name=u'Product.name', sale=False),
Expand Down Expand Up @@ -83,3 +85,11 @@ def test_service_client_payload_serialization():
'g': 1234,
'hh': 'text data',
}


def test_service_client_representation():
if PY2:
assert repr(SampleService.Client) == "<class 'fixture.foo.Client'>"
else:
assert repr(SampleService.Client) == \
"<class 'fixture.foo.SampleService.Client'>"