Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
7f04d69a
Commit
7f04d69a
authored
11 months ago
by
Adam Laskowski
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-14382: fixed clearing of vocabulary properties
parent
c9ccb3f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api-openbis-python3-pybis/src/python/pybis/property.py
+3
-3
3 additions, 3 deletions
api-openbis-python3-pybis/src/python/pybis/property.py
api-openbis-python3-pybis/src/python/tests/test_vocabulary.py
+80
-0
80 additions, 0 deletions
...openbis-python3-pybis/src/python/tests/test_vocabulary.py
with
83 additions
and
3 deletions
api-openbis-python3-pybis/src/python/pybis/property.py
+
3
−
3
View file @
7f04d69a
...
@@ -146,15 +146,15 @@ class PropertyHolder:
...
@@ -146,15 +146,15 @@ class PropertyHolder:
if
type
(
value
)
!=
list
:
if
type
(
value
)
!=
list
:
value
=
[
value
]
value
=
[
value
]
for
single_value
in
value
:
for
single_value
in
value
:
if
str
(
single_value
).
upper
()
not
in
terms
.
df
[
"
code
"
].
values
:
if
single_value
!=
''
and
str
(
single_value
).
upper
()
not
in
terms
.
df
[
"
code
"
].
values
:
raise
ValueError
(
raise
ValueError
(
f
"
Value for attribute «
{
name
}
» must be one of these terms:
{
'
,
'
.
join
(
terms
.
df
[
'
code
'
].
values
)
}
"
f
"
Value for attribute «
{
name
}
» must be one of these terms:
{
'
,
'
.
join
(
terms
.
df
[
'
code
'
].
values
)
}
"
)
)
else
:
else
:
value
=
str
(
value
).
upper
()
value
=
str
(
value
).
upper
()
if
value
not
in
terms
.
df
[
"
code
"
].
values
:
if
value
!=
''
and
value
not
in
terms
.
df
[
"
code
"
].
values
:
raise
ValueError
(
raise
ValueError
(
f
"
Value for attribute «
{
name
}
» must be one of these terms:
{
'
,
'
.
join
(
terms
.
df
[
'
code
'
].
values
)
}
"
f
"
Value for attribute «
{
name
}
» must be one of these terms:
{
'
,
'
.
join
(
terms
.
df
[
'
code
'
].
values
)
}
VALUE:
{
value
}
"
)
)
elif
data_type
==
"
SAMPLE
"
:
elif
data_type
==
"
SAMPLE
"
:
if
"
multiValue
"
in
property_type
and
property_type
[
"
multiValue
"
]
is
True
:
if
"
multiValue
"
in
property_type
and
property_type
[
"
multiValue
"
]
is
True
:
...
...
This diff is collapsed.
Click to expand it.
api-openbis-python3-pybis/src/python/tests/test_vocabulary.py
+
80
−
0
View file @
7f04d69a
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
import
random
import
random
import
time
import
time
import
uuid
def
test_create_delete_vocabulary
(
openbis_instance
):
def
test_create_delete_vocabulary
(
openbis_instance
):
...
@@ -83,4 +84,83 @@ def test_create_delete_vocabulary_term(openbis_instance):
...
@@ -83,4 +84,83 @@ def test_create_delete_vocabulary_term(openbis_instance):
assert
list
(
terms
.
df
[
'
code
'
])
==
[
'
TERM_CODE1
'
,
'
TERM_CODE2
'
]
assert
list
(
terms
.
df
[
'
code
'
])
==
[
'
TERM_CODE1
'
,
'
TERM_CODE2
'
]
def
test_create_set_and_remove_vocabulary_property
(
space
):
o
=
space
.
openbis
timestamp
=
time
.
strftime
(
'
%a_%y%m%d_%H%M%S
'
).
upper
()
voc_code
=
'
test_voc_
'
+
timestamp
+
"
_
"
+
str
(
random
.
randint
(
0
,
1000
))
voc
=
o
.
new_vocabulary
(
code
=
voc_code
,
description
=
'
description of vocabulary
'
,
urlTemplate
=
'
https://ethz.ch
'
,
terms
=
[
{
"
code
"
:
'
term_code1
'
,
"
label
"
:
"
term_label1
"
,
"
description
"
:
"
term_description1
"
},
{
"
code
"
:
'
term_code2
'
,
"
label
"
:
"
term_label2
"
,
"
description
"
:
"
term_description2
"
},
{
"
code
"
:
'
term_code3
'
,
"
label
"
:
"
term_label3
"
,
"
description
"
:
"
term_description3
"
}
],
chosenFromList
=
False
)
voc
.
save
()
voc_exists
=
o
.
get_vocabulary
(
voc_code
)
assert
voc_exists
is
not
None
assert
voc_exists
.
code
==
voc_code
.
upper
()
property_type_code
=
"
test_vocabulary_property_type_
"
+
timestamp
+
"
_
"
+
str
(
uuid
.
uuid4
())
pt_date
=
o
.
new_property_type
(
code
=
property_type_code
,
label
=
'
custom property of data type controlled vocabulary
'
,
description
=
'
custom property created in unit test
'
,
dataType
=
'
CONTROLLEDVOCABULARY
'
,
vocabulary
=
voc_code
)
pt_date
.
save
()
# Create custom sample type
sample_type_code
=
"
test_sample_type_
"
+
timestamp
+
"
_
"
+
str
(
uuid
.
uuid4
())
sample_type
=
o
.
new_sample_type
(
code
=
sample_type_code
,
generatedCodePrefix
=
"
S
"
,
autoGeneratedCode
=
True
,
listable
=
True
,
)
sample_type
.
save
()
# Assign created property to new sample type
sample_type
.
assign_property
(
prop
=
property_type_code
,
section
=
'
vocabulary section
'
,
ordinal
=
1
,
mandatory
=
False
,
showInEditView
=
True
,
showRawValueInForms
=
True
)
project
=
space
.
new_project
(
f
'
my_project_
{
timestamp
}
'
)
project
.
save
()
collection
=
o
.
new_experiment
(
'
UNKNOWN
'
,
f
'
my_collection_
{
timestamp
}
'
,
project
)
collection
.
save
()
sample_code
=
"
my_sample_{}
"
.
format
(
timestamp
)
sample
=
space
.
new_sample
(
code
=
sample_code
,
type
=
sample_type_code
,
experiment
=
collection
,
props
=
{
property_type_code
.
lower
():
'
term_code1
'
})
sample
.
save
()
assert
len
(
sample
.
props
())
==
1
key
,
val
=
sample
.
props
().
popitem
()
assert
key
.
lower
()
==
property_type_code
.
lower
()
assert
val
==
'
term_code1
'
.
upper
()
sample
.
props
[
property_type_code
.
lower
()]
=
''
sample
.
save
()
assert
len
(
sample
.
props
())
==
1
key
,
val
=
sample
.
props
().
popitem
()
assert
key
.
lower
()
==
property_type_code
.
lower
()
assert
val
==
''
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