Mark signing identities as such in Identity.__repr__
This commit is contained in:
parent
d602d9c3ba
commit
547c6b5205
@ -56,6 +56,9 @@ class Identity:
|
||||
return f'@{self.name}.{base32_bytes_to_string(self.verify_key.to_bytes())}'
|
||||
|
||||
def __repr__(self) -> str:
|
||||
if self.sign_key:
|
||||
return f'<Identity (signer) {self}>'
|
||||
|
||||
return f'<Identity {self}>'
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
|
@ -67,7 +67,18 @@ def test_str(identity: Identity) -> None:
|
||||
@pytest.mark.id_key_seed(TEST_SEED)
|
||||
@pytest.mark.id_name('test')
|
||||
def test_repr(identity: Identity) -> None:
|
||||
"""Test if the __str__ method returns the author address"""
|
||||
"""Test if the __repr__ method returns the author address"""
|
||||
|
||||
assert (
|
||||
repr(identity)
|
||||
== '<Identity (signer) @test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya>'
|
||||
)
|
||||
|
||||
|
||||
def test_repr_nosign() -> None:
|
||||
"""Test the __repr__ method marks the identity as a signer in the output"""
|
||||
|
||||
identity = Identity.from_address('@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya')
|
||||
|
||||
assert (
|
||||
repr(identity) == '<Identity @test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya>'
|
||||
|
Loading…
Reference in New Issue
Block a user