Skip to content

Commit

Permalink
feat(responsetemplate): add isPending method
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Apr 16, 2019
1 parent fd4c2cb commit c429972
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions hexonet/apiconnector/responsetemplate.py
Expand Up @@ -95,3 +95,11 @@ def isTmpError(self):
Check if current API response represents a temporary error case (4xx)
"""
return self.__hash["CODE"][0] == "4"

def isPending(self):
"""
Check if current operation is returned as pending
"""
if 'PENDING' in self.__hash:
return self.__hash["PENDING"] == "1"
return False
2 changes: 1 addition & 1 deletion src/pytestcov
Submodule pytestcov updated from 720542 to 408261
8 changes: 8 additions & 0 deletions tests/test_responsetemplate.py
Expand Up @@ -25,3 +25,11 @@ def test_responsetemplatemethods():
assert tpl.getRuntime() == 0.00
# [in api response]
assert tpl2.getRuntime() == 0.12

# #.isPending
# [not in api response]
assert tpl.isPending() == False
# [in api response]
tpl2 = ResponseTemplate(
'[RESPONSE]\r\ncode=423\r\ndescription=Empty API response\r\npending=1\r\nEOF\r\n')
assert tpl2.isPending()

0 comments on commit c429972

Please sign in to comment.