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
9e8cbc7c
Commit
9e8cbc7c
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: tests that check the details of scanning applied to scifolder
parent
a99460a9
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!160
STY: styling
,
!124
More scifolder scanner unittests
Pipeline
#38410
passed with warnings
1 year 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_scanner.py
+78
-0
78 additions, 0 deletions
unittests/test_scanner.py
with
78 additions
and
0 deletions
unittests/test_scanner.py
+
78
−
0
View file @
9e8cbc7c
...
...
@@ -167,3 +167,81 @@ def test_record_structure_generation():
assert
subc
[
0
][
"
Measurement
"
]
is
False
assert
subc
[
0
][
"
date
"
]
is
False
assert
subc
[
0
][
"
identifier
"
]
is
False
def
test_record_generation
():
"""
Test the correct list of returned records by the scanner using the
scifolder example from the article.
"""
records
=
scan_directory
(
UNITTESTDIR
/
"
test_directories
"
/
"
examples_article
"
,
UNITTESTDIR
/
"
scifolder_cfood.yml
"
)
def
parent_filter
(
parent_name
):
return
[
p
for
p
in
records
if
len
(
p
.
parents
)
==
1
and
p
.
parents
[
0
].
name
==
parent_name
]
def
check_properties
(
records
,
check_props
,
check_additional
=
True
):
records_found
=
[
0
for
r
in
check_props
]
for
rec
in
records
:
rec_found
=
0
# Try each record to check
for
i
,
check_prop
in
enumerate
(
check_props
):
matches
=
True
# breakpoint()
# Verify that all props are in the record and have the right value
for
pr
in
check_prop
:
if
rec
.
get_property
(
pr
)
is
None
:
matches
=
False
break
if
check_prop
[
pr
]
is
None
:
if
rec
.
get_property
(
pr
).
value
is
not
None
:
matches
=
False
break
else
:
if
rec
.
get_property
(
pr
).
value
!=
check_prop
[
pr
]:
matches
=
False
break
if
check_additional
:
# Verify that there are no additional props in the record
for
rpr
in
rec
.
properties
:
if
rpr
.
name
not
in
check_prop
:
matches
=
False
break
if
matches
:
records_found
[
i
]
+=
1
return
records_found
# Check projects:
# Ther are two projects in mixed categories: climate_model_predict and SpeedOfLight
projects_found
=
check_properties
(
parent_filter
(
"
Project
"
),
[
{
"
identifier
"
:
"
climate-model-predict
"
,
"
date
"
:
"
2020
"
},
{
"
identifier
"
:
"
SpeedOfLight
"
,
"
date
"
:
"
2020
"
}
])
assert
projects_found
==
[
3
,
2
]
measurements
=
parent_filter
(
"
Measurement
"
)
assert
len
(
measurements
)
==
11
measurements_found
=
check_properties
(
measurements
,
[
{
"
identifier
"
:
"
prediction-errors
"
,
"
date
"
:
"
2020-02-08
"
},
{
"
identifier
"
:
"
average-all-exp
"
,
"
date
"
:
"
2020-01-04
"
},
{
"
identifier
"
:
"
average-all-exp-corr
"
,
"
date
"
:
"
2020-01-05
"
},
{
"
date
"
:
"
1980-01-01
"
,
"
identifier
"
:
None
},
{
"
date
"
:
"
1990-01-01
"
,
"
identifier
"
:
None
},
{
"
date
"
:
"
2000-01-01
"
,
"
identifier
"
:
None
},
{
"
date
"
:
"
2010-01-01
"
,
"
identifier
"
:
None
},
{
"
date
"
:
"
2020-01-01
"
,
"
identifier
"
:
"
TimeOfFlight
"
},
{
"
date
"
:
"
2020-01-02
"
,
"
identifier
"
:
"
Cavity
"
},
{
"
date
"
:
"
2020-01-03
"
,
"
identifier
"
:
None
},
{
"
date
"
:
"
2020-02-01
"
,
"
identifier
"
:
None
},
],
False
)
for
f
in
measurements_found
:
assert
f
==
1
persons
=
parent_filter
(
"
Person
"
)
check_props
=
[
{
"
first_name
"
:
None
,
"
last_name
"
:
"
Author
"
+
letter
}
for
letter
in
(
"
A
"
,
"
B
"
,
"
C
"
,
"
D
"
,
"
E
"
)]
persons_found
=
check_properties
(
persons
,
check_props
)
for
f
in
persons_found
:
assert
f
>
0
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