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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
bb672942
Commit
bb672942
authored
2 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: Revert renaming of variable and use better RT names in test
parent
d8546bf6
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!71
REL: RElease v0.2.0
,
!5
FIX: use identifiable instead of record
Pipeline
#29511
passed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/crawl.py
+3
-3
3 additions, 3 deletions
src/caoscrawler/crawl.py
unittests/test_tool.py
+9
-9
9 additions, 9 deletions
unittests/test_tool.py
with
12 additions
and
12 deletions
src/caoscrawler/crawl.py
+
3
−
3
View file @
bb672942
...
...
@@ -482,16 +482,16 @@ class Crawler(object):
return
self
.
_synchronize
(
self
.
target_data
,
commit_changes
,
unique_names
=
unique_names
)
def
has_reference_value_without_id
(
self
,
identifiable
:
db
.
Record
):
def
has_reference_value_without_id
(
self
,
record
:
db
.
Record
):
"""
Returns True if there is at least one property in `
identifiable
` which:
Returns True if there is at least one property in `
record
` which:
a) is a reference property AND
b) where the value is set to a db.Entity (instead of an ID) AND
c) where the ID of the value (the db.Entity object in b)) is not set (to an integer)
Returns False otherwise.
"""
for
p
in
identifiable
.
properties
:
for
p
in
record
.
properties
:
if
isinstance
(
p
.
value
,
list
):
for
el
in
p
.
value
:
if
isinstance
(
el
,
db
.
Entity
)
and
el
.
id
is
None
:
...
...
This diff is collapsed.
Click to expand it.
unittests/test_tool.py
+
9
−
9
View file @
bb672942
...
...
@@ -502,39 +502,39 @@ def test_has_missing_object_in_references(crawler):
# Simulate remote server content by using the names to identify records
# There are only two known Records with name A and B
crawler
.
identifiableAdapter
.
get_registered_identifiable
=
Mock
(
side_effect
=
partial
(
basic_retrieve_by_name_mock_up
,
known
=
{
"
C
"
:
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
)
basic_retrieve_by_name_mock_up
,
known
=
{
"
C
"
:
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
RT
C
"
)
.
add_property
(
"
d
"
),
"
D
"
:
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
"
D
"
:
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
RT
D
"
)
.
add_property
(
"
d
"
).
add_property
(
"
e
"
),
}))
# one reference with id -> check
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
)
.
add_parent
(
"
C
"
).
add_property
(
'
d
'
,
123
))
.
add_parent
(
"
RT
C
"
).
add_property
(
'
d
'
,
123
))
# one ref with Entity with id -> check
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
)
.
add_parent
(
"
C
"
)
.
add_parent
(
"
RT
C
"
)
.
add_property
(
'
d
'
,
db
.
Record
(
id
=
123
)
.
add_parent
(
"
C
"
)))
# one ref with id one with Entity with id (mixed) -> check
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
D
"
)
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
RT
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)
.
add_parent
(
"
C
"
)))
.
add_parent
(
"
RT
C
"
)))
# entity to be referenced in the following
a
=
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
).
add_property
(
"
d
"
,
12311
)
# one ref with id one with Entity without id (but not identifying) -> fail
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
)
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
RT
C
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
# one ref with id one with Entity without id (mixed) -> fail
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
assert
not
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
RT
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
crawler
.
add_to_remote_missing_cache
(
a
)
# one ref with id one with Entity without id but in cache -> check
assert
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
assert
crawler
.
has_missing_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
RT
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
# if this ever fails, the mock up may be removed
...
...
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