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
1b0d1a5e
Commit
1b0d1a5e
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: reuse code
parent
8404dd9e
No related branches found
No related tags found
2 merge requests
!123
REL: Release v0.6.0
,
!113
F refactor test tool
Pipeline
#36644
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
unittests/test_crawler.py
+8
-1
8 additions, 1 deletion
unittests/test_crawler.py
unittests/test_file_identifiables.py
+2
-10
2 additions, 10 deletions
unittests/test_file_identifiables.py
with
10 additions
and
11 deletions
unittests/test_crawler.py
+
8
−
1
View file @
1b0d1a5e
...
...
@@ -84,7 +84,7 @@ NEW_ELEMENT = (db.Record()
.
add_property
(
name
=
"
result
"
,
value
=
"
homogeneous
"
))
def
mock_get_entity_by
(
eid
=
None
,
name
=
None
):
def
mock_get_entity_by
(
eid
=
None
,
name
=
None
,
path
=
None
):
if
eid
is
not
None
:
candidates
=
[
el
for
el
in
EXAMPLE_SERVER_STATE
if
el
.
id
==
eid
]
if
len
(
candidates
)
>
0
:
...
...
@@ -98,6 +98,13 @@ def mock_get_entity_by(eid=None, name=None):
return
candidates
[
0
]
else
:
raise
EmptyUniqueQueryError
(
""
)
if
path
is
not
None
:
candidates
=
[
el
for
el
in
EXAMPLE_SERVER_STATE
if
(
el
.
path
is
not
None
and
el
.
path
==
path
)]
if
len
(
candidates
)
>
0
:
return
candidates
[
0
]
else
:
raise
EmptyUniqueQueryError
(
""
)
@pytest.fixture
(
autouse
=
True
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_file_identifiables.py
+
2
−
10
View file @
1b0d1a5e
...
...
@@ -12,22 +12,14 @@ from caosdb.cached import cache_clear
from
caosdb.exceptions
import
EmptyUniqueQueryError
from
pytest
import
raises
from
test_crawler
import
mock_get_entity_by
@pytest.fixture
(
autouse
=
True
)
def
clear_cache
():
cache_clear
()
def
mock_get_entity_by
(
eid
=
None
,
name
=
None
,
path
=
None
):
if
eid
is
not
None
:
candidates
=
[
el
for
el
in
EXAMPLE_SERVER_STATE
if
el
.
id
==
eid
]
if
len
(
candidates
)
>
0
:
return
candidates
[
0
]
else
:
raise
EmptyUniqueQueryError
(
""
)
raise
EmptyUniqueQueryError
(
""
)
@patch
(
"
caoscrawler.identifiable_adapters.cached_get_entity_by
"
,
new
=
Mock
(
side_effect
=
mock_get_entity_by
))
def
test_file_identifiable
():
...
...
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