Skip to content

Commit

Permalink
fix: fix the case that include_failed cannot be set to False.
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 24, 2019
1 parent 0ea1090 commit 6af1f9b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stellar_sdk/call_builder/base_call_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def _add_query_param(self, key: str, value: Union[str, float, int, bool, None]):
pass
elif value is True:
self.params[key] = "true"
elif value is False:
self.params[key] = "false"
else:
self.params[key] = str(value)

Expand Down
12 changes: 12 additions & 0 deletions tests/call_builder/test_operations_call_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ def test_include_failed(self):
account_id=account_id
)
assert builder.params == {"include_failed": "true"}

def test_not_include_failed(self):
account_id = "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"
builder = (
OperationsCallBuilder(horizon_url, client)
.for_account(account_id)
.include_failed(False)
)
assert builder.endpoint == "accounts/{account_id}/operations".format(
account_id=account_id
)
assert builder.params == {"include_failed": "false"}
12 changes: 12 additions & 0 deletions tests/call_builder/test_payments_call_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ def test_include_failed(self):
account_id=account_id
)
assert builder.params == {"include_failed": "true"}

def test_not_include_failed(self):
account_id = "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"
builder = (
PaymentsCallBuilder(horizon_url, client)
.for_account(account_id)
.include_failed(False)
)
assert builder.endpoint == "accounts/{account_id}/payments".format(
account_id=account_id
)
assert builder.params == {"include_failed": "false"}
12 changes: 12 additions & 0 deletions tests/call_builder/test_transactions_call_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ def test_include_failed(self):
account_id=account_id
)
assert builder.params == {"include_failed": "true"}

def test_not_include_failed(self):
account_id = "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"
builder = (
TransactionsCallBuilder(horizon_url, client)
.for_account(account_id)
.include_failed(False)
)
assert builder.endpoint == "accounts/{account_id}/transactions".format(
account_id=account_id
)
assert builder.params == {"include_failed": "false"}

0 comments on commit 6af1f9b

Please sign in to comment.