Replace fetch_identity function names

to better show what they do
master
juga 2 years ago
parent 531b242ebd
commit 1c17cb00c4

@ -35,12 +35,12 @@ class GNUnetRest:
r = requests.get(self.identity)
return r.json() if r.ok else (False, r.reason)
def fetch_identity_name(self, name):
def fetch_identity_keyhash(self, name):
"""Returns the public key of an identity specified by name."""
r = requests.get(self.identity_hash + name)
return r.json()['name'] if r.ok else (False, r.reason)
def fetch_identity_hash(self, key_hash):
def fetch_identity_name(self, key_hash):
"""Returns the name of an identity specified by public key."""
r = requests.get(self.identity_name + key_hash)
return r.json()['pubkey'] if r.ok else (False, r.reason)

@ -37,21 +37,21 @@ def test_list_identities():
def test_fetch_identity_hash():
conn = gnunetrest.GNUnetRest()
conn.create_identity("alice")
r = conn.fetch_identity_hash("alice")
r = conn.fetch_identity_name("alice")
assert 52 == len(r)
# def test_fetch_identity_name():
# conn = gnunetrest.GNUnetRest()
# conn.create_identity("alice")
# r = conn.fetch_identity_name("alice")
# r = conn.fetch_identity_keyhash("alice")
def test_change_identity_name():
conn = gnunetrest.GNUnetRest()
conn.create_identity("alice")
assert conn.change_identity_name("alice", "carol")
r = conn.fetch_identity_hash("carol")
r = conn.fetch_identity_name("carol")
assert 52 == len(r)
@ -59,7 +59,7 @@ def test_delete_identity():
conn = gnunetrest.GNUnetRest()
conn.create_identity("alice")
assert conn.delete_identity("alice")
assert not conn.fetch_identity_hash("alice")[0]
assert not conn.fetch_identity_name("alice")[0]
# # NAMESTORE#

Loading…
Cancel
Save