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
c3f53f94
Verified
Commit
c3f53f94
authored
9 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
TEST for
#95
: Merging two entities that are referenced by a third.
parent
1813a3a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!173
ENH: Better errors for identifiables.yaml and when record type does not exist
Pipeline
#52447
failed
9 months 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_adapters.py
+5
-0
5 additions, 0 deletions
src/caoscrawler/identifiable_adapters.py
unittests/test_sync_graph.py
+25
-0
25 additions, 0 deletions
unittests/test_sync_graph.py
with
30 additions
and
0 deletions
src/caoscrawler/identifiable_adapters.py
+
5
−
0
View file @
c3f53f94
...
...
@@ -576,6 +576,11 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
"""
Load identifiables defined in a yaml file
"""
with
open
(
path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
yaml_f
:
identifiable_data
=
yaml
.
safe_load
(
yaml_f
)
self
.
load_from_yaml_object
(
identifiable_data
)
def
load_from_yaml_object
(
self
,
identifiable_data
):
"""
Load identifiables defined in a yaml object.
"""
for
key
,
value
in
identifiable_data
.
items
():
rt
=
db
.
RecordType
().
add_parent
(
key
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_sync_graph.py
+
25
−
0
View file @
c3f53f94
...
...
@@ -651,3 +651,28 @@ def test_set_each_scalar_value():
assert
a
.
properties
[
0
].
value
==
42
_set_each_scalar_value
(
a
,
lambda
x
:
x
==
42
,
lambda
x
:
None
)
assert
a
.
properties
[
0
].
value
is
None
def
test_merge_referenced_by
():
"""
Merging two entities that are referenced by a third entity.
See also https://gitlab.com/linkahead/linkahead-crawler/-/issues/95
"""
ident
=
CaosDBIdentifiableAdapter
()
ident
.
load_from_yaml_object
({
"
RT_A
"
:
[
"
name
"
],
"
RT_B
"
:
[{
"
is_referenced_by
"
:
"
RT_A
"
},
"
my_id
"
]
})
crawled_data
:
list
=
[]
references
:
list
=
[]
for
ii
in
[
0
,
1
]:
rec
=
db
.
Record
().
add_parent
(
"
RT_B
"
).
add_property
(
"
my_id
"
,
value
=
ii
)
references
.
append
(
rec
)
crawled_data
.
append
(
rec
)
rec_a
=
db
.
Record
(
name
=
"
A
"
).
add_parent
(
"
RT_A
"
)
rec_a
.
add_property
(
"
my_ref
"
,
value
=
references
)
crawled_data
.
append
(
rec_a
)
sync_graph
=
SyncGraph
(
crawled_data
,
ident
)
assert
sync_graph
is
not
None
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