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
fb183efb
Commit
fb183efb
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX test
parent
12a41936
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!160
STY: styling
,
!131
Accept references of children
Pipeline
#40918
failed
1 year 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
+7
-2
7 additions, 2 deletions
src/caoscrawler/identifiable_adapters.py
unittests/test_crawler.py
+5
-1
5 additions, 1 deletion
unittests/test_crawler.py
with
12 additions
and
3 deletions
src/caoscrawler/identifiable_adapters.py
+
7
−
2
View file @
fb183efb
...
...
@@ -40,6 +40,12 @@ from .utils import has_parent
logger
=
logging
.
getLogger
(
__name__
)
def
get_children_of_rt
(
rtname
):
"""
Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list
"""
return
[
p
.
name
for
p
in
db
.
execute_query
(
f
"
FIND RECORDTYPE
{
givenrt
}
"
)]
def
convert_value
(
value
:
Any
):
"""
Returns a string representation of the value that is suitable
to be used in the query
...
...
@@ -213,8 +219,7 @@ identifiabel, identifiable and identified record) for a Record.
# separate class too
if
prop
.
name
.
lower
()
==
"
is_referenced_by
"
:
for
givenrt
in
prop
.
value
:
rt_and_children
=
[
p
.
name
for
p
in
db
.
execute_query
(
f
"
FIND RECORDTYPE
{
givenrt
}
"
)]
rt_and_children
=
get_children_of_rt
(
givenrt
)
found
=
False
for
rtname
in
rt_and_children
:
if
(
id
(
record
)
in
referencing_entities
...
...
This diff is collapsed.
Click to expand it.
unittests/test_crawler.py
+
5
−
1
View file @
fb183efb
...
...
@@ -607,7 +607,7 @@ def test_create_flat_list():
assert
c
in
flat
@
pytest
.
fixture
@pytest.fixture
def
crawler_mocked_for_backref_test
():
crawler
=
Crawler
()
# mock retrieval of registered identifiabls: return Record with just a parent
...
...
@@ -685,6 +685,8 @@ def test_split_into_inserts_and_updates_backref(crawler_mocked_for_backref_test)
assert
insert
[
0
].
name
==
"
B
"
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
id
()))
def
test_split_into_inserts_and_updates_mult_backref
(
crawler_mocked_for_backref_test
):
# test whether multiple references of the same record type are correctly used
crawler
=
crawler_mocked_for_backref_test
...
...
@@ -705,6 +707,8 @@ def test_split_into_inserts_and_updates_mult_backref(crawler_mocked_for_backref_
assert
len
(
insert
)
==
2
@patch
(
"
caoscrawler.identifiable_adapters.get_children_of_rt
"
,
new
=
Mock
(
side_effect
=
id
()))
def
test_split_into_inserts_and_updates_diff_backref
(
crawler_mocked_for_backref_test
):
# test whether multiple references of the different record types are correctly used
crawler
=
crawler_mocked_for_backref_test
...
...
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