Skip to content
Snippets Groups Projects
Commit d75b3948 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

ENH: add nice string representation for identifiables

parent 6cf10a47
No related branches found
No related tags found
2 merge requests!91Release 0.3,!73ENH: add representation to identifiables
Pipeline #31000 failed
......@@ -22,6 +22,7 @@
from __future__ import annotations
import caosdb as db
from datetime import datetime
import json
from hashlib import sha256
from typing import Union
......@@ -127,3 +128,10 @@ class Identifiable():
return True
else:
return False
def __repr__(self):
pstring = json.dumps(self.properties)
return (f"{self.__class__.__name__} for RT {self.record_type}: id={self.record_id}; "
f"name={self.name}\n\tpath={self.path}\n"
f"\tproperties:\n{pstring}\n"
f"\tbackrefs:\n{self.backrefs}")
......@@ -65,6 +65,11 @@ def test_name():
Identifiable(properties={"Name": 'li'})
def test_repr():
# only test that something meaningful is returned
assert 'properties' str(Identifiable(name="A", record_type="B"))
def test_equality():
assert Identifiable(
record_id=12, properties={"a": 0}) == Identifiable(record_id=12, properties={"a": 1})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment