Skip to content

Commit 2169891

Browse files
fix(APIClient): return APIClient instance in setUserAgent method
use this to improve code by method chaining
1 parent 1823117 commit 2169891

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

hexonet/apiconnector/apiclient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def setUserAgent(self, pid, rv):
9393
pf = platform.system()
9494
arch = platform.architecture()[0]
9595
self.__ua = "%s (%s; %s; rv:%s) python-sdk/%s python/%s" % (pid, pf, arch, rv, self.getVersion(), pyv)
96+
return self
9697

9798
def getVersion(self):
9899
"""

tests/test_apiclient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ def test_apiclientmethods():
122122
pf = platform.system()
123123
arch = platform.architecture()[0]
124124
ua = "%s (%s; %s; rv:%s) %s/%s python/%s" % (pid, pf, arch, rv, pid2, cl.getVersion(), pyv)
125-
cl.setUserAgent(pid, rv)
125+
cl2 = cl.setUserAgent(pid, rv)
126+
assert isinstance(cl2, AC) is True
126127
assert cl.getUserAgent() == ua
127128

128129
# #.setURL()

0 commit comments

Comments
 (0)