Fix or complete tests

- replace True asserts by the specific type
- stop re-creating REST objects in succesive test
- complete tests with assertions
master
juga 2 years ago
parent 206e7eba0c
commit a3275f274b

@ -19,21 +19,21 @@ def test_connect():
# ==========#
def test_create_identity():
print("\nCreating some identities")
# The request works, but doesn't create the identity
assert REST_CLIENT.create_identity("alice")
r = REST_CLIENT.create_identity("alice")
assert r is True
r = REST_CLIENT.create_identity("bob")
assert r is True
def test_list_identities():
REST_CLIENT.create_identity("alice")
REST_CLIENT.create_identity("bob")
identities = REST_CLIENT.identity_list()
print(identities)
# This fail!
assert 2 == len(identities)
assert "alice" == identities[0]['name']
assert "bob" == identities[1]['name']
def test_fetch_identity_hash():
REST_CLIENT.create_identity("alice")
r = REST_CLIENT.fetch_identity_name("alice")
assert 52 == len(r)
@ -45,16 +45,14 @@ def test_fetch_identity_hash():
def test_change_identity_name():
REST_CLIENT.create_identity("alice")
assert REST_CLIENT.change_identity_name("alice", "carol")
assert REST_CLIENT.change_identity_name("bob", "carol")
r = REST_CLIENT.fetch_identity_name("carol")
assert 52 == len(r)
def test_delete_identity():
REST_CLIENT.create_identity("alice")
assert REST_CLIENT.delete_identity("alice")
assert not REST_CLIENT.fetch_identity_name("alice")[0]
assert REST_CLIENT.delete_identity("carol") is True
assert REST_CLIENT.fetch_identity_name("carol")[0] is False
# # NAMESTORE#
@ -70,12 +68,13 @@ def test_fetch_namestore_default_identity():
def test_add_namestore_entry():
assert REST_CLIENT.add_namestore_entry(
r = REST_CLIENT.add_namestore_entry(
"alice",
"pepfoundation",
"95.128.36.146",
"A"
)
assert r is True
def test_change_namestore_entry():
@ -85,26 +84,43 @@ def test_change_namestore_entry():
"6.6.6.6",
"A"
)
r = REST_CLIENT.list_namestore_entries("alice")
assert 1 == len(r)
assert 'pepfoundation' == r[0]['record_name']
# It would modify any record that match all the flags, ending with only
# one, even for repeated records.
assert '6.6.6.6' == [record['value'] for record in r[0]['data']][0]
def test_delete_namestore_entry():
assert REST_CLIENT.delete_namestore_entry("alice", "pepfoundation")
r = REST_CLIENT.delete_namestore_entry("alice", "pepfoundation")
assert r is True
r = REST_CLIENT.list_namestore_entries("alice")
# There should not be anymore records with that record name
assert 0 == len(r)
# # GNS#
# # ===#
def test_list_gns_record():
# Add an entry again, since it was deleted
r = REST_CLIENT.add_namestore_entry(
"alice",
"pepfoundation",
"95.128.36.146",
"A"
)
assert r is True
r = REST_CLIENT.list_gns_record("alice", "pepfoundation")
print(r)
assert r[0]
assert r['record_name'] == 'pepfoundation.alice'
assert r['data']
assert isinstance(r, dict)
assert 'pepfoundation.alice' == r['record_name']
assert '95.128.36.146' == r["data"][0]["value"]
def test_list_gns_record_type():
r = REST_CLIENT.list_gns_record_type("alice", "pepfoundation", "A")
print(r)
assert r[0]
assert r['record_name'] == 'pepfoundation.alice'
assert r['data']
assert isinstance(r, dict)
assert 'pepfoundation.alice' == r['record_name']
# Even if there're several records, all should be type A
assert 'A' == r['data'][0]['record_type']

Loading…
Cancel
Save