From 3504d048e1937ff8ef5c07c38e68d2aa4496c5e1 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sat, 19 Mar 2022 14:00:45 +0100 Subject: [PATCH] [mod] #89: Use {Revocation,Identity}.__eq__() method Implemented in DunitePy v1.1 --- silkaj/idty_tools.py | 3 +-- tests/test_revocation.py | 27 ++------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/silkaj/idty_tools.py b/silkaj/idty_tools.py index 7b9b30c4..e9a6575b 100644 --- a/silkaj/idty_tools.py +++ b/silkaj/idty_tools.py @@ -69,8 +69,7 @@ def check_many_identities(idty: Identity, doc_type: str = "Identity"): lookup_ids = merge_ids_lists(results_pubkey, results_uid, idty.currency) match = False for n, lookup in enumerate(lookup_ids): - # __equal"__ method does not work. - if idty.signed_raw() == lookup.signed_raw(): + if idty == lookup: lookup_ids.pop(n) match = True break diff --git a/tests/test_revocation.py b/tests/test_revocation.py index afc9fafc..edabb87a 100644 --- a/tests/test_revocation.py +++ b/tests/test_revocation.py @@ -42,29 +42,6 @@ from silkaj.tui import display_pubkey_and_checksum ### useful function ### -def assertEqual(test: Revocation, expected: Revocation): - """ - Checks the equality of two revocation objects. - Should be replaced by 'Revoc1 == Revoc2' once __eq__() method has been published in Duniterpy. - """ - # direct equality fails, I can't find why. - # assert test == expected - # so, let's test all values. - assert test.version == expected.version - assert test.currency == expected.currency - assert test.pubkey == expected.pubkey - # fields for identity - assert test.identity.version == expected.identity.version - assert test.identity.currency == expected.identity.currency - assert test.identity.pubkey == expected.identity.pubkey - assert test.identity.uid == expected.identity.uid - assert test.identity.block_id == expected.identity.block_id - assert test.identity.signature == expected.identity.signature - # test raw and inline are the same - assert test.raw() == expected.raw() - assert test.inline() == expected.inline() - - def display_dry_options(display, dry_run): if display: return ["--display"] @@ -943,7 +920,7 @@ def test_create_revocation_doc(idty, lookup): currency="g1-test", identity=idty, ) - assertEqual(test, expected) + assert test == expected # test save_doc @@ -1019,7 +996,7 @@ def test_verify_document(doc, lookup, capsys, monkeypatch): if len(lookup["results"]) > 1: assert "One matching identity!\n" in display assert "Similar identities:" in display - assertEqual(result, doc) + assert result == doc # test verify_document: no matching identity -- GitLab