Skip to content

Commit

Permalink
fix(APIClient): return APIClient instance in setUserAgent method
Browse files Browse the repository at this point in the history
use this to improve code by method chaining
  • Loading branch information
KaiSchwarz-cnic committed Apr 4, 2019
1 parent 1823117 commit 2169891
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions hexonet/apiconnector/apiclient.py
Expand Up @@ -93,6 +93,7 @@ def setUserAgent(self, pid, rv):
pf = platform.system()
arch = platform.architecture()[0]
self.__ua = "%s (%s; %s; rv:%s) python-sdk/%s python/%s" % (pid, pf, arch, rv, self.getVersion(), pyv)
return self

def getVersion(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_apiclient.py
Expand Up @@ -122,7 +122,8 @@ def test_apiclientmethods():
pf = platform.system()
arch = platform.architecture()[0]
ua = "%s (%s; %s; rv:%s) %s/%s python/%s" % (pid, pf, arch, rv, pid2, cl.getVersion(), pyv)
cl.setUserAgent(pid, rv)
cl2 = cl.setUserAgent(pid, rv)
assert isinstance(cl2, AC) is True
assert cl.getUserAgent() == ua

# #.setURL()
Expand Down

0 comments on commit 2169891

Please sign in to comment.