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
19a84b75
Commit
19a84b75
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
clean up
parent
04bcb680
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
#29353
failed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_tool.py
+15
-47
15 additions, 47 deletions
unittests/test_tool.py
with
15 additions
and
47 deletions
unittests/test_tool.py
+
15
−
47
View file @
19a84b75
...
...
@@ -505,35 +505,6 @@ def test_split_into_inserts_and_updates_with_copy_attr(crawler_mocked_identifiab
crawler
.
identifiableAdapter
.
retrieve_identified_record_for_record
.
assert_called
()
def
test_all_references_are_existing_already2
(
crawler
):
registered_identifiables
=
{
"
C
"
:
db
.
Record
().
add_parent
(
"
C
"
).
add_property
(
"
a
"
),
"
D
"
:
db
.
Record
().
add_parent
(
"
D
"
).
add_property
(
"
a
"
).
add_property
(
"
b
"
)}
crawler
.
identifiableAdapter
.
get_registered_identifiable
=
Mock
(
side_effect
=
partial
(
basic_ident_lookup
,
idents
=
registered_identifiables
))
# one reference with id
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
().
add_parent
(
"
C
"
).
add_property
(
'
a
'
,
123
))
# one ref with id one with Entity with id
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
().
add_parent
(
"
D
"
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)))
a
=
db
.
Record
(
name
=
"
A
"
).
add_parent
(
"
C
"
).
add_property
(
"
a
"
,
12311
)
# one ref with id one with Entity without id
assert
not
crawler
.
all_references_are_existing_already
(
db
.
Record
().
add_parent
(
"
D
"
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
a
))
crawler
.
add_identified_record_to_local_cache
(
a
)
# one ref with id one with Entity which is cached
# (RT C has a as identifying prop which is given in this example)
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
().
add_parent
(
"
D
"
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
a
))
# if this ever fails, the mock up may be removed
crawler
.
identifiableAdapter
.
get_registered_identifiable
.
assert_called
()
def
test_all_references_are_existing_already
(
crawler
):
# Simulate remote server content by using the names to identify records
# There are only two known Records with name A and B
...
...
@@ -544,18 +515,29 @@ def test_all_references_are_existing_already(crawler):
.
add_property
(
"
d
"
).
add_property
(
"
e
"
),
}))
# one reference with id -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
).
add_property
(
'
d
'
,
123
))
# one ref with Entity with id -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
)
.
add_property
(
'
d
'
,
db
.
Record
(
id
=
123
)))
# 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
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)))
# 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) -> check
assert
crawler
.
all_references_are_existing_already
(
db
.
Record
(
name
=
"
C
"
).
add_parent
(
"
C
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
# 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
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
crawler
.
add_identified_record_to_local_cache
(
a
)
# 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
"
)
.
add_property
(
'
d
'
,
123
)
.
add_property
(
'
e
'
,
a
))
...
...
@@ -563,34 +545,20 @@ def test_all_references_are_existing_already(crawler):
crawler
.
identifiableAdapter
.
get_registered_identifiable
.
assert_called
()
def
test_can_be_checked_externally2
(
crawler
):
registered_identifiables
=
{
"
C
"
:
db
.
Record
().
add_parent
(
"
C
"
).
add_property
(
"
a
"
),
"
D
"
:
db
.
Record
().
add_parent
(
"
D
"
).
add_property
(
"
a
"
).
add_property
(
"
b
"
)}
crawler
.
identifiableAdapter
.
get_registered_identifiable
=
Mock
(
side_effect
=
partial
(
basic_ident_lookup
,
idents
=
registered_identifiables
))
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
C
"
).
add_property
(
'
a
'
,
123
))
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
C
"
)
.
add_property
(
'
a
'
,
db
.
Record
(
id
=
123
)))
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
D
"
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
(
id
=
123
)))
assert
not
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
D
"
)
.
add_property
(
'
a
'
,
123
)
.
add_property
(
'
b
'
,
db
.
Record
()))
def
test_can_be_checked_externally
(
crawler
,
ident
):
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
Person
"
).
add_property
(
'
last_name
'
,
123
).
add_property
(
'
first_name
'
,
123
))
# id and rec with id
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
Person
"
)
.
add_property
(
'
first_name
'
,
123
)
.
add_property
(
'
last_name
'
,
db
.
Record
(
id
=
123
)))
# id and rec with id and one unneeded prop
assert
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
Person
"
)
.
add_property
(
'
first_name
'
,
123
)
.
add_property
(
'
stuff
'
,
db
.
Record
())
.
add_property
(
'
last_name
'
,
db
.
Record
(
id
=
123
)))
# one identifying prop is missing
assert
not
crawler
.
can_be_checked_externally
(
db
.
Record
().
add_parent
(
"
Person
"
)
.
add_property
(
'
first_name
'
,
123
)
.
add_property
(
'
last_name
'
,
db
.
Record
()))
...
...
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