Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
d75b3948
Commit
d75b3948
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add nice string representation for identifiables
parent
6cf10a47
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!91
Release 0.3
,
!73
ENH: add representation to identifiables
Pipeline
#31000
failed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/identifiable.py
+8
-0
8 additions, 0 deletions
src/caoscrawler/identifiable.py
unittests/test_identifiable.py
+5
-0
5 additions, 0 deletions
unittests/test_identifiable.py
with
13 additions
and
0 deletions
src/caoscrawler/identifiable.py
+
8
−
0
View file @
d75b3948
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
from
__future__
import
annotations
from
__future__
import
annotations
import
caosdb
as
db
import
caosdb
as
db
from
datetime
import
datetime
from
datetime
import
datetime
import
json
from
hashlib
import
sha256
from
hashlib
import
sha256
from
typing
import
Union
from
typing
import
Union
...
@@ -127,3 +128,10 @@ class Identifiable():
...
@@ -127,3 +128,10 @@ class Identifiable():
return
True
return
True
else
:
else
:
return
False
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\t
path=
{
self
.
path
}
\n
"
f
"
\t
properties:
\n
{
pstring
}
\n
"
f
"
\t
backrefs:
\n
{
self
.
backrefs
}
"
)
This diff is collapsed.
Click to expand it.
unittests/test_identifiable.py
+
5
−
0
View file @
d75b3948
...
@@ -65,6 +65,11 @@ def test_name():
...
@@ -65,6 +65,11 @@ def test_name():
Identifiable
(
properties
=
{
"
Name
"
:
'
li
'
})
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
():
def
test_equality
():
assert
Identifiable
(
assert
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
0
})
==
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
1
})
record_id
=
12
,
properties
=
{
"
a
"
:
0
})
==
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
1
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment