mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-19 17:14:33 +00:00
api: identities returns a single object instead of a list if address is set.
This commit is contained in:
parent
2929e74c78
commit
c5ced6994a
2 changed files with 18 additions and 15 deletions
|
@ -707,7 +707,10 @@ def js_identities(self, url_split, post_string: str, is_json: bool) -> bytes:
|
|||
ensure("address" in filters, "Must provide an address to modify data")
|
||||
swap_client.setIdentityData(filters, set_data)
|
||||
|
||||
return bytes(json.dumps(swap_client.listIdentities(filters)), "UTF-8")
|
||||
rv = swap_client.listIdentities(filters)
|
||||
if "address" in filters:
|
||||
rv = {} if len(rv) < 1 else rv[0]
|
||||
return bytes(json.dumps(rv), "UTF-8")
|
||||
|
||||
|
||||
def js_automationstrategies(self, url_split, post_string: str, is_json: bool) -> bytes:
|
||||
|
|
|
@ -186,17 +186,17 @@ class Test(BaseTest):
|
|||
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
|
||||
{"set_label": "test 1"},
|
||||
)
|
||||
assert len(rv) == 1
|
||||
assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv[0]["label"] == "test 1"
|
||||
assert isinstance(rv, dict)
|
||||
assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv["label"] == "test 1"
|
||||
rv = read_json_api(
|
||||
1800,
|
||||
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
|
||||
{"set_label": "test 2"},
|
||||
)
|
||||
assert len(rv) == 1
|
||||
assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv[0]["label"] == "test 2"
|
||||
assert isinstance(rv, dict)
|
||||
assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv["label"] == "test 2"
|
||||
|
||||
rv = read_json_api(
|
||||
1800,
|
||||
|
@ -210,26 +210,26 @@ class Test(BaseTest):
|
|||
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
|
||||
{"set_note": "note 1"},
|
||||
)
|
||||
assert len(rv) == 1
|
||||
assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv[0]["label"] == "test 2"
|
||||
assert rv[0]["note"] == "note 1"
|
||||
assert isinstance(rv, dict)
|
||||
assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
|
||||
assert rv["label"] == "test 2"
|
||||
assert rv["note"] == "note 1"
|
||||
|
||||
rv = read_json_api(
|
||||
1800,
|
||||
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
|
||||
{"set_automation_override": 1},
|
||||
)
|
||||
assert len(rv) == 1
|
||||
assert rv[0]["automation_override"] == 1
|
||||
assert isinstance(rv, dict)
|
||||
assert rv["automation_override"] == 1
|
||||
|
||||
rv = read_json_api(
|
||||
1800,
|
||||
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
|
||||
{"set_visibility_override": "hide"},
|
||||
)
|
||||
assert len(rv) == 1
|
||||
assert rv[0]["visibility_override"] == 1
|
||||
assert isinstance(rv, dict)
|
||||
assert rv["visibility_override"] == 1
|
||||
|
||||
rv = read_json_api(1800, "automationstrategies")
|
||||
assert len(rv) == 2
|
||||
|
|
Loading…
Reference in a new issue