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
f08bd180
Commit
f08bd180
authored
11 months ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX: setting of id
parent
38483610
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Pipeline
#51822
failed
11 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/caoscrawler/sync_node.py
+8
-4
8 additions, 4 deletions
src/caoscrawler/sync_node.py
unittests/test_identifiable_adapters.py
+3
-0
3 additions, 0 deletions
unittests/test_identifiable_adapters.py
unittests/test_sync_graph.py
+10
-1
10 additions, 1 deletion
unittests/test_sync_graph.py
with
21 additions
and
5 deletions
src/caoscrawler/sync_node.py
+
8
−
4
View file @
f08bd180
...
@@ -68,15 +68,17 @@ class SyncNode(db.Entity):
...
@@ -68,15 +68,17 @@ class SyncNode(db.Entity):
"""
"""
def
__init__
(
def
__init__
(
self
,
entity
:
db
.
Entity
,
registered_identifiable
:
Optional
[
db
.
RecordType
]
=
None
self
,
entity
:
db
.
Entity
,
registered_identifiable
:
Optional
[
db
.
RecordType
]
=
None
,
**
kwargs
):
):
super
().
__init__
(
name
=
entity
.
name
,
id
=
entity
.
id
,
description
=
entity
.
description
,
**
kwargs
)
# db.Entity properties
# db.Entity properties
self
.
id
:
Union
[
int
,
TempID
,
str
]
=
entity
.
id
self
.
role
=
entity
.
role
self
.
role
=
entity
.
role
self
.
path
=
entity
.
path
self
.
path
=
entity
.
path
self
.
file
=
entity
.
file
self
.
file
=
entity
.
file
self
.
name
=
entity
.
name
self
.
description
=
entity
.
description
self
.
parents
=
_ParentList
().
extend
(
entity
.
parents
)
self
.
parents
=
_ParentList
().
extend
(
entity
.
parents
)
self
.
properties
=
_Properties
().
extend
(
entity
.
properties
)
self
.
properties
=
_Properties
().
extend
(
entity
.
properties
)
self
.
_check_for_multiproperties
()
self
.
_check_for_multiproperties
()
...
@@ -193,6 +195,7 @@ class SyncNode(db.Entity):
...
@@ -193,6 +195,7 @@ class SyncNode(db.Entity):
{
{
"
id
"
:
self
.
id
,
"
id
"
:
self
.
id
,
"
name
"
:
self
.
name
,
"
name
"
:
self
.
name
,
"
path
"
:
self
.
path
,
"
parents
"
:
[
el
.
name
for
el
in
self
.
parents
],
"
parents
"
:
[
el
.
name
for
el
in
self
.
parents
],
},
},
allow_unicode
=
True
,
allow_unicode
=
True
,
...
@@ -211,6 +214,7 @@ class SyncNode(db.Entity):
...
@@ -211,6 +214,7 @@ class SyncNode(db.Entity):
{
{
"
id
"
:
el
.
id
,
"
id
"
:
el
.
id
,
"
name
"
:
el
.
name
,
"
name
"
:
el
.
name
,
"
path
"
:
el
.
path
,
"
parents
"
:
[
e
.
name
for
e
in
el
.
parents
],
"
parents
"
:
[
e
.
name
for
e
in
el
.
parents
],
}
}
)
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_identifiable_adapters.py
+
3
−
0
View file @
f08bd180
...
@@ -29,6 +29,7 @@ test identifiable_adapters module
...
@@ -29,6 +29,7 @@ test identifiable_adapters module
import
os
import
os
from
datetime
import
datetime
from
datetime
import
datetime
from
unittest.mock
import
MagicMock
,
Mock
,
patch
from
pathlib
import
Path
from
pathlib
import
Path
import
caosdb
as
db
import
caosdb
as
db
...
@@ -249,6 +250,8 @@ def test_retrieve_identified_record_for_identifiable():
...
@@ -249,6 +250,8 @@ def test_retrieve_identified_record_for_identifiable():
assert
r_cur
.
description
==
idr_r1
.
description
assert
r_cur
.
description
==
idr_r1
.
description
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_referencing_entity_has_appropriate_type
():
def
test_referencing_entity_has_appropriate_type
():
dummy
=
db
.
Record
().
add_parent
(
"
A
"
)
dummy
=
db
.
Record
().
add_parent
(
"
A
"
)
registered_identifiable
=
db
.
RecordType
()
registered_identifiable
=
db
.
RecordType
()
...
...
This diff is collapsed.
Click to expand it.
unittests/test_sync_graph.py
+
10
−
1
View file @
f08bd180
...
@@ -100,7 +100,8 @@ def test_create_flat_list():
...
@@ -100,7 +100,8 @@ def test_create_flat_list():
assert
d
in
flat
assert
d
in
flat
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_create_reference_mapping
():
def
test_create_reference_mapping
():
a
=
SyncNode
(
db
.
Record
().
add_parent
(
"
RT1
"
),
a
=
SyncNode
(
db
.
Record
().
add_parent
(
"
RT1
"
),
db
.
RecordType
().
add_property
(
"
is_referenced_by
"
,
[
"
RT2
"
]))
db
.
RecordType
().
add_property
(
"
is_referenced_by
"
,
[
"
RT2
"
]))
...
@@ -201,6 +202,8 @@ def test_SyncGraph_init():
...
@@ -201,6 +202,8 @@ def test_SyncGraph_init():
assert
el
.
identifiable
is
not
None
or
el
.
id
is
not
None
assert
el
.
identifiable
is
not
None
or
el
.
id
is
not
None
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_merge_into_trivial
(
simple_adapter
):
def
test_merge_into_trivial
(
simple_adapter
):
# simplest case: a -> c
# simplest case: a -> c
# b
# b
...
@@ -277,6 +280,8 @@ def test_merge_into_trivial(simple_adapter):
...
@@ -277,6 +280,8 @@ def test_merge_into_trivial(simple_adapter):
assert
se_b
in
st
.
backward_references_backref
[
id
(
se_c
)]
assert
se_b
in
st
.
backward_references_backref
[
id
(
se_c
)]
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_merge_into_simple
(
simple_adapter
):
def
test_merge_into_simple
(
simple_adapter
):
# simple case: a -> c <- b (a & b reference c; a & b have the same target record)
# simple case: a -> c <- b (a & b reference c; a & b have the same target record)
c
=
db
.
Record
(
name
=
'
c
'
).
add_parent
(
"
RT2
"
)
c
=
db
.
Record
(
name
=
'
c
'
).
add_parent
(
"
RT2
"
)
...
@@ -356,6 +361,8 @@ def test_merge_into_simple(simple_adapter):
...
@@ -356,6 +361,8 @@ def test_merge_into_simple(simple_adapter):
se_b
in
st
.
backward_references_backref
[
id
(
se_c
)]
se_b
in
st
.
backward_references_backref
[
id
(
se_c
)]
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_backward_references_backref
():
def
test_backward_references_backref
():
# We use the reference as identifying reference in both directions. Thus the map is the same
# We use the reference as identifying reference in both directions. Thus the map is the same
# for all three categories: references, id_references and id_referenced_by
# for all three categories: references, id_references and id_referenced_by
...
@@ -372,6 +379,8 @@ def test_backward_references_backref():
...
@@ -372,6 +379,8 @@ def test_backward_references_backref():
assert
st
.
nodes
[
1
]
in
st
.
backward_references_backref
[
id
(
st
.
nodes
[
0
])]
assert
st
.
nodes
[
1
]
in
st
.
backward_references_backref
[
id
(
st
.
nodes
[
0
])]
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
lambda
x
:
[
x
]))
def
test_set_id_of_node
(
simple_adapter
):
def
test_set_id_of_node
(
simple_adapter
):
# setting the id should lead to the node being marked as existing
# setting the id should lead to the node being marked as existing
ent_list
=
[
db
.
Record
(
name
=
'
a
'
).
add_parent
(
"
RT5
"
)]
ent_list
=
[
db
.
Record
(
name
=
'
a
'
).
add_parent
(
"
RT5
"
)]
...
...
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