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
4d6ce2d1
Commit
4d6ce2d1
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: rename func
parent
92b6f9d6
No related branches found
No related tags found
3 merge requests
!71
REL: RElease v0.2.0
,
!56
F refactor
,
!5
FIX: use identifiable instead of record
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/crawl.py
+6
-4
6 additions, 4 deletions
src/caoscrawler/crawl.py
unittests/test_tool.py
+15
-15
15 additions, 15 deletions
unittests/test_tool.py
with
21 additions
and
19 deletions
src/caoscrawler/crawl.py
+
6
−
4
View file @
4d6ce2d1
...
@@ -531,10 +531,12 @@ class Crawler(object):
...
@@ -531,10 +531,12 @@ class Crawler(object):
# TODO: move inside if block?
# TODO: move inside if block?
self
.
create_flat_list
([
p
.
value
],
flat
)
self
.
create_flat_list
([
p
.
value
],
flat
)
def
all_references_are_existing_already
(
self
,
record
:
db
.
Record
):
def
no_uncached_entity_object_in_references
(
self
,
record
:
db
.
Record
):
"""
"""
returns true if all references either have IDs or were checked remotely and not found (i.e.
returns False if any property value is a db.Entity object that does not have an ID and also
they exist in the local cache)
is not contained in the local cache. For example, if it was checked before whether such an
db.Entity object existed remotely and it was not found, it would have been added to the
local cache.
"""
"""
for
p
in
record
.
properties
:
for
p
in
record
.
properties
:
# if (is_reference(p)
# if (is_reference(p)
...
@@ -716,7 +718,7 @@ class Crawler(object):
...
@@ -716,7 +718,7 @@ class Crawler(object):
resolved_references
=
True
resolved_references
=
True
# e.g. references an identifiable that does not exist remotely
# e.g. references an identifiable that does not exist remotely
elif
self
.
all_references_are_existing_already
(
record
):
elif
self
.
no_uncached_entity_object_in_references
(
record
):
# TODO: (for review)
# TODO: (for review)
# This was the old version, but also for this case the
# This was the old version, but also for this case the
...
...
This diff is collapsed.
Click to expand it.
unittests/test_tool.py
+
15
−
15
View file @
4d6ce2d1
...
@@ -509,31 +509,31 @@ def test_all_references_are_existing_already(crawler):
...
@@ -509,31 +509,31 @@ def test_all_references_are_existing_already(crawler):
}))
}))
# one reference with id -> check
# one reference with id -> check
assert
crawler
.
all_references_are_existing_already
(
assert
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
).
add_property
(
'
d
'
,
123
))
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
).
add_property
(
'
d
'
,
123
))
# one ref with Entity with id -> check
# one ref with Entity with id -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
)
assert
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
C
"
)
.
add_property
(
'
d
'
,
db
.
Record
(
id
=
123
)))
.
add_property
(
'
d
'
,
db
.
Record
(
id
=
123
)))
# one ref with id one with Entity with id (mixed) -> check
# one ref with id one with Entity with id (mixed) -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
D
"
)
assert
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)))
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)))
# entity to be referenced in the following
# entity to be referenced in the following
a
=
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
).
add_property
(
"
d
"
,
12311
)
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
# one ref with id one with Entity without id (but not identifying) -> fail
assert
not
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
)
assert
not
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
.
add_property
(
'
e
'
,
a
))
# one ref with id one with Entity without id (mixed) -> fail
# one ref with id one with Entity without id (mixed) -> fail
assert
not
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
assert
not
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
.
add_property
(
'
e
'
,
a
))
crawler
.
add_identified_record_to_local_cache
(
a
)
crawler
.
add_identified_record_to_local_cache
(
a
)
# one ref with id one with Entity without id but in cache -> check
# one ref with id one with Entity without id but in cache -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
assert
crawler
.
no_uncached_entity_object_in_references
(
db
.
Record
(
name
=
"
D
"
).
add_parent
(
"
D
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
.
add_property
(
'
e
'
,
a
))
# if this ever fails, the mock up may be removed
# if this ever fails, the mock up may be removed
crawler
.
identifiableAdapter
.
get_registered_identifiable
.
assert_called
()
crawler
.
identifiableAdapter
.
get_registered_identifiable
.
assert_called
()
...
...
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