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
f17c6102
Commit
f17c6102
authored
3 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: fixed tests due to changes to rocrate feature
parent
c3a6f565
No related branches found
No related tags found
2 merge requests
!217
TST: Make NamedTemporaryFiles Windows-compatible
,
!215
Fix issues in rocrate support
Pipeline
#60454
passed
3 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/converters/rocrate.py
+8
-4
8 additions, 4 deletions
src/caoscrawler/converters/rocrate.py
unittests/test_rocrate_converter.py
+13
-6
13 additions, 6 deletions
unittests/test_rocrate_converter.py
with
21 additions
and
10 deletions
src/caoscrawler/converters/rocrate.py
+
8
−
4
View file @
f17c6102
...
...
@@ -200,12 +200,16 @@ class ROCrateEntityConverter(Converter):
# This is - according to the standard - only allowed, if it's flat, i.e.
# it contains a single element with key == "@id" and the id as value which
# is supposed to be dereferenced:
if
not
(
len
(
value
)
==
1
and
"
@id
"
in
eprops
):
if
not
(
len
(
value
)
==
1
and
"
@id
"
in
value
):
raise
RuntimeError
(
"
The JSON-LD is not flat.
"
)
children
.
append
(
ROCrateEntity
(
element
.
folder
,
element
.
entity
.
crate
.
dereference
(
value
[
"
@id
"
])))
# TODO: tests missing!
dereferenced
=
element
.
entity
.
crate
.
dereference
(
value
[
"
@id
"
])
if
dereferenced
is
not
None
:
children
.
append
(
ROCrateEntity
(
element
.
folder
,
dereferenced
))
else
:
# This is just an external ID and will be added as simple DictElement
children
.
append
(
convert_basic_element
(
value
,
name
))
else
:
children
.
append
(
convert_basic_element
(
value
,
name
))
...
...
This diff is collapsed.
Click to expand it.
unittests/test_rocrate_converter.py
+
13
−
6
View file @
f17c6102
...
...
@@ -144,8 +144,8 @@ match_properties:
assert
isinstance
(
children
[
0
],
TextElement
)
assert
children
[
0
].
name
==
"
@id
"
assert
children
[
0
].
value
==
"
ro-crate-metadata.json
"
assert
isinstance
(
children
[
5
],
DictElement
)
assert
children
[
5
].
valu
e
==
{
'
@id
'
:
'
https://kadi.iam.kit.edu
'
}
assert
isinstance
(
children
[
5
],
ROCrateEntity
)
assert
children
[
5
].
nam
e
==
"
https://kadi.iam.kit.edu
"
def
test_file
(
eln_entities
):
...
...
@@ -184,13 +184,20 @@ match_properties:
assert
match
is
not
None
children
=
ds_parts
.
create_children
(
GeneralStore
(),
ent_parts
)
# Number of children = number of properties + number of parts +
# number of variables measured + number of files
assert
len
(
children
)
==
(
len
(
ent_parts
.
entity
.
properties
())
+
len
(
ent_parts
.
entity
.
properties
()[
"
hasPart
"
])
+
len
(
ent_parts
.
entity
.
properties
()[
"
variableMeasured
"
]))
# Number of children = number of properties + number of parts:
assert
len
(
children
)
==
len
(
ent_parts
.
entity
.
properties
())
+
4
entity_children
=
[
f
for
f
in
children
if
isinstance
(
f
,
ROCrateEntity
)]
assert
len
(
entity_children
)
==
4
assert
len
(
entity_children
)
==
13
file_counter
=
0
for
f
in
entity_children
:
assert
isinstance
(
f
.
entity
,
rocrate
.
model
.
file
.
File
)
if
isinstance
(
f
.
entity
,
rocrate
.
model
.
file
.
File
):
file_counter
+=
1
assert
file_counter
==
4
def
test_scanner
():
...
...
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