Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Coscine Python SDK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
community features
Coscine Python SDK
Commits
41333d54
Commit
41333d54
authored
11 months ago
by
Romin
Browse files
Options
Downloads
Patches
Plain Diff
Add metadata_form test
parent
49348c94
No related branches found
No related tags found
No related merge requests found
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+21
-0
21 additions, 0 deletions
.gitlab-ci.yml
tests/test_metadata_form.py
+39
-0
39 additions, 0 deletions
tests/test_metadata_form.py
with
60 additions
and
0 deletions
.gitlab-ci.yml
+
21
−
0
View file @
41333d54
...
@@ -159,6 +159,27 @@ integration testing:
...
@@ -159,6 +159,27 @@ integration testing:
paths
:
paths
:
-
./report.md
-
./report.md
###############################################################################
# This job tests the sourcecode in the python module.
###############################################################################
test metadata conformity
:
stage
:
test
tags
:
-
"
runner:docker"
-
"
env:devlef"
image
:
python:latest
before_script
:
-
python -V
-
pip install .
script
:
-
COSCINE_API_TOKEN=${COSCINE_API_TOKEN}
-
python ./tests/test_metadata_form.py
when
:
manual
artifacts
:
paths
:
-
./test-metadata-form-results.txt
###############################################################################
###############################################################################
# This job builds and deploys the Coscine Python SDK packge to the
# This job builds and deploys the Coscine Python SDK packge to the
# Python Package index (PyPi). It is triggered with a new GitLab commit tag.
# Python Package index (PyPi). It is triggered with a new GitLab commit tag.
...
...
This diff is collapsed.
Click to expand it.
tests/test_metadata_form.py
0 → 100644
+
39
−
0
View file @
41333d54
import
logging
from
os
import
getenv
import
coscine
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
"
test
"
)
def
main
(
fp
):
token
=
getenv
(
"
COSCINE_API_TOKEN
"
)
if
not
token
:
raise
ValueError
(
"
No Coscine API Token specified!
"
"
Create a new environment variable with
"
"
the name COSCINE_API_TOKEN!
"
)
client
=
coscine
.
ApiClient
(
token
)
application_profiles
=
client
.
application_profiles
()
count
=
len
(
application_profiles
)
valid
=
0
invalid
=
0
for
index
,
ap
in
enumerate
(
application_profiles
):
print
(
f
"
AP
{
index
}
/
{
count
}
{
ap
.
uri
}
"
,
file
=
fp
)
try
:
form
=
coscine
.
MetadataForm
(
client
.
application_profile
(
ap
.
uri
))
form
.
test
()
print
(
form
,
file
=
fp
)
is_valid
=
form
.
validate
()
print
(
f
"
Valid:
{
is_valid
}
"
,
file
=
fp
)
valid
+=
1
except
Exception
as
ex
:
print
(
f
"
Valid:
{
False
}
"
,
file
=
fp
)
print
(
ex
,
file
=
fp
)
invalid
+=
1
print
(
f
"
Valid:
{
valid
}
"
,
file
=
fp
)
print
(
f
"
Invalid:
{
invalid
}
"
,
file
=
fp
)
print
(
f
"
Total:
{
count
}
"
,
file
=
fp
)
with
open
(
"
test-metadata-form-results.txt
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
fp
:
main
(
fp
)
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