Skip to content

Commit

Permalink
#167: Add Client class under Service class
Browse files Browse the repository at this point in the history
  • Loading branch information
qria committed Feb 9, 2018
1 parent f449697 commit 9f2c36d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Nirum/Targets/Python.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,12 @@ class {className}_Client($className):
self.__nirum_transport__ = transport # type: transport_type

{clientMethods'}

{className}.Client = {className}_Client
if hasattr({className}.Client, '__qualname__'):
{className}.Client.__qualname__ = '{className}.Client'
else:
{className}.Client.__name__ = '{className}.Client'
|]
where
nirumMapName :: T.Text
Expand Down
10 changes: 8 additions & 2 deletions test/python/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from nirum.transport import Transport

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 +48,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 +84,8 @@ def test_service_client_payload_serialization():
'g': 1234,
'hh': 'text data',
}


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

0 comments on commit 9f2c36d

Please sign in to comment.