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
d83c3008
Commit
d83c3008
authored
5 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
STY: autopep8'd
parent
009e2c07
No related branches found
No related tags found
2 merge requests
!217
TST: Make NamedTemporaryFiles Windows-compatible
,
!212
ENH: introduce inheritance of identifiables
Pipeline
#59891
passed with warnings
5 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
+3
-6
3 additions, 6 deletions
src/caoscrawler/identifiable_adapters.py
unittests/test_crawler.py
+13
-10
13 additions, 10 deletions
unittests/test_crawler.py
with
16 additions
and
16 deletions
src/caoscrawler/identifiable_adapters.py
+
3
−
6
View file @
d83c3008
...
@@ -45,12 +45,13 @@ from .utils import has_parent
...
@@ -45,12 +45,13 @@ from .utils import has_parent
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
def
_retrieve_RecordType
(
id
=
None
,
name
=
None
):
def
_retrieve_RecordType
(
id
=
None
,
name
=
None
):
"""
"""
Retrieve the RecordType from LinkAhead. For mocking purposes.
Retrieve the RecordType from LinkAhead. For mocking purposes.
"""
"""
return
db
.
RecordType
(
name
=
name
,
id
=
id
).
retrieve
()
return
db
.
RecordType
(
name
=
name
,
id
=
id
).
retrieve
()
def
get_children_of_rt
(
rtname
):
def
get_children_of_rt
(
rtname
):
"""
Supply the name of a recordtype. This name and the name of all children RTs are returned in
"""
Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list
"""
a list
"""
...
@@ -658,8 +659,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
...
@@ -658,8 +659,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
return
registered
[
0
]
return
registered
[
0
]
else
:
else
:
return
None
return
None
def
_get_registered_for_rt
(
self
,
rt
:
db
.
RecordType
):
def
_get_registered_for_rt
(
self
,
rt
:
db
.
RecordType
):
"""
"""
returns the registered identifiable for the given RecordType or the
returns the registered identifiable for the given RecordType or the
...
@@ -681,9 +681,6 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
...
@@ -681,9 +681,6 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
return
registered
[
0
]
return
registered
[
0
]
else
:
else
:
return
None
return
None
def
retrieve_identified_record_for_identifiable
(
self
,
identifiable
:
Identifiable
):
def
retrieve_identified_record_for_identifiable
(
self
,
identifiable
:
Identifiable
):
query_string
=
self
.
create_query_for_identifiable
(
identifiable
)
query_string
=
self
.
create_query_for_identifiable
(
identifiable
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_crawler.py
+
13
−
10
View file @
d83c3008
...
@@ -371,8 +371,9 @@ def test_split_into_inserts_and_updates_with_circ(crawler_mocked_identifiable_re
...
@@ -371,8 +371,9 @@ def test_split_into_inserts_and_updates_with_circ(crawler_mocked_identifiable_re
with
pytest
.
raises
(
RuntimeError
):
with
pytest
.
raises
(
RuntimeError
):
crawler
.
_split_into_inserts_and_updates
(
st
)
crawler
.
_split_into_inserts_and_updates
(
st
)
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
def
test_split_into_inserts_and_updates_with_complex
(
crawler_mocked_identifiable_retrieve
):
def
test_split_into_inserts_and_updates_with_complex
(
crawler_mocked_identifiable_retrieve
):
crawler
=
crawler_mocked_identifiable_retrieve
crawler
=
crawler_mocked_identifiable_retrieve
# A
# A
...
@@ -400,8 +401,9 @@ def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable
...
@@ -400,8 +401,9 @@ def test_split_into_inserts_and_updates_with_complex(crawler_mocked_identifiable
# TODO write test where the unresoled entity is not part of the identifiable
# TODO write test where the unresoled entity is not part of the identifiable
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
@patch
(
"
caoscrawler.identifiable_adapters.cached_query
"
,
@patch
(
"
caoscrawler.identifiable_adapters.cached_query
"
,
...
@@ -584,8 +586,9 @@ def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_
...
@@ -584,8 +586,9 @@ def test_split_into_inserts_and_updates_diff_backref(crawler_mocked_for_backref_
assert
len
(
update
)
==
2
assert
len
(
update
)
==
2
assert
len
(
insert
)
==
1
assert
len
(
insert
)
==
1
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
def
test_replace_entities_with_ids
():
def
test_replace_entities_with_ids
():
crawler
=
Crawler
()
crawler
=
Crawler
()
a
=
(
db
.
Record
().
add_parent
(
"
B
"
).
add_property
(
"
A
"
,
12345
)
a
=
(
db
.
Record
().
add_parent
(
"
B
"
).
add_property
(
"
A
"
,
12345
)
...
@@ -598,8 +601,8 @@ def test_replace_entities_with_ids():
...
@@ -598,8 +601,8 @@ def test_replace_entities_with_ids():
assert
a
.
get_property
(
"
C
"
).
value
==
[
12345
,
233324
]
assert
a
.
get_property
(
"
C
"
).
value
==
[
12345
,
233324
]
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
@patch
(
"
caoscrawler.identifiable_adapters.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.identifiable_adapters.cached_get_entity_by
"
,
...
@@ -625,8 +628,8 @@ def test_synchronization_no_commit(upmock, insmock):
...
@@ -625,8 +628,8 @@ def test_synchronization_no_commit(upmock, insmock):
assert
len
(
ups
)
==
1
assert
len
(
ups
)
==
1
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
@patch
(
"
caoscrawler.identifiable_adapters._retrieve_RecordType
"
,
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
new
=
Mock
(
side_effect
=
lambda
id
,
name
:
db
.
RecordType
(
id
=
id
,
name
=
name
)))
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.crawl.cached_get_entity_by
"
,
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
@patch
(
"
caoscrawler.identifiable_adapters.cached_get_entity_by
"
,
@patch
(
"
caoscrawler.identifiable_adapters.cached_get_entity_by
"
,
...
...
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