Skip to content

Commit 5893d55

Browse files
committed
#167: Add Client class under Service class
1 parent f449697 commit 5893d55

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Nirum/Targets/Python.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,12 @@ class {className}_Client($className):
11231123
self.__nirum_transport__ = transport # type: transport_type
11241124

11251125
{clientMethods'}
1126+
1127+
{className}.Client = {className}_Client
1128+
if hasattr({className}.Client, '__qualname__'):
1129+
{className}.Client.__qualname__ = '{className}.Client'
1130+
else:
1131+
{className}.Client.__name__ = 'Client'
11261132
|]
11271133
where
11281134
nirumMapName :: T.Text

test/python/service_test.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import uuid
22

33
from nirum.transport import Transport
4+
from six import PY2
45

56
from fixture.foo import (Dog, Gender, PingService, Product, RpcError,
6-
SampleService_Client, Way)
7+
SampleService, SampleService_Client, Way)
78

89

910
def test_throws_error():
@@ -48,7 +49,8 @@ def latest_call(self):
4849

4950
def test_service_client_payload_serialization():
5051
t = DumbTransport()
51-
c = SampleService_Client(t)
52+
c = SampleService.Client(t)
53+
assert SampleService_Client is SampleService.Client
5254
c.sample_method(
5355
a=Dog(name=u'Dog.name', age=3),
5456
b=Product(name=u'Product.name', sale=False),
@@ -83,3 +85,11 @@ def test_service_client_payload_serialization():
8385
'g': 1234,
8486
'hh': 'text data',
8587
}
88+
89+
90+
def test_service_client_representation():
91+
if PY2:
92+
assert repr(SampleService.Client) == "<class 'fixture.foo.Client'>"
93+
else:
94+
assert repr(SampleService.Client) == \
95+
"<class 'fixture.foo.SampleService.Client'>"

0 commit comments

Comments
 (0)