Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SMASCH
scheduling-system
Commits
be7db0fd
Commit
be7db0fd
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
test checking if rendered inital value of the custom field is valid
parent
bb264c09
No related branches found
No related tags found
1 merge request
!265
Resolve "configurable study fields"
Pipeline
#34100
failed
4 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/forms/study_subject_forms.py
+1
-1
1 addition, 1 deletion
smash/web/forms/study_subject_forms.py
smash/web/tests/forms/test_StudySubjectEditForm.py
+19
-1
19 additions, 1 deletion
smash/web/tests/forms/test_StudySubjectEditForm.py
with
20 additions
and
2 deletions
smash/web/forms/study_subject_forms.py
+
1
−
1
View file @
be7db0fd
...
...
@@ -63,7 +63,7 @@ def create_field_for_custom_study_subject_field(study_subject_field: CustomStudy
required
=
study_subject_field
.
obligatory
,
disabled
=
study_subject_field
.
readonly
,
widget
=
forms
.
DateInput
(
DATEPICKER_DATE_ATTRS
,
"
%Y-%m-%d
"
))
elif
study_subject_field
.
type
==
CUSTOM_FIELD_TYPE_SELECT_LIST
:
initial
=
None
initial
=
'
0
'
for
v
,
k
in
get_custom_select_choices
(
study_subject_field
.
possible_values
):
if
k
==
val
:
initial
=
v
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/forms/test_StudySubjectEditForm.py
+
19
−
1
View file @
be7db0fd
...
...
@@ -5,7 +5,7 @@ from parameterized import parameterized
from
web.forms
import
StudySubjectEditForm
from
web.models
import
StudySubject
from
web.models.constants
import
CUSTOM_FIELD_TYPE_TEXT
,
CUSTOM_FIELD_TYPE_BOOLEAN
,
CUSTOM_FIELD_TYPE_INTEGER
,
\
CUSTOM_FIELD_TYPE_DOUBLE
,
CUSTOM_FIELD_TYPE_DATE
,
CUSTOM_FIELD_TYPE_SELECT_LIST
CUSTOM_FIELD_TYPE_DOUBLE
,
CUSTOM_FIELD_TYPE_DATE
,
CUSTOM_FIELD_TYPE_SELECT_LIST
,
CUSTOM_FIELD_TYPE_FILE
from
web.models.custom_data
import
CustomStudySubjectField
from
web.models.custom_data.custom_study_subject_field
import
get_study_subject_field_id
from
web.tests
import
LoggedInWithWorkerTestCase
...
...
@@ -82,6 +82,24 @@ class StudySubjectEditFormTests(LoggedInWithWorkerTestCase):
self
.
assertEqual
(
expected_serialized_value
,
subject
.
get_custom_data_value
(
field
).
value
)
@parameterized.expand
([
(
'
text
'
,
CUSTOM_FIELD_TYPE_TEXT
,
'
bla
'
,
'
bla
'
),
(
'
bool
'
,
CUSTOM_FIELD_TYPE_BOOLEAN
,
True
,
'
True
'
),
(
'
int
'
,
CUSTOM_FIELD_TYPE_INTEGER
,
10
,
'
10
'
),
(
'
double
'
,
CUSTOM_FIELD_TYPE_DOUBLE
,
30.5
,
'
30.5
'
),
(
'
date
'
,
CUSTOM_FIELD_TYPE_DATE
,
'
2020-11-05
'
,
'
2020-11-05
'
),
(
'
select list
'
,
CUSTOM_FIELD_TYPE_SELECT_LIST
,
'
1
'
,
'
BLA
'
,
'
BLA;BLA-BLA
'
),
(
'
select list empty value
'
,
CUSTOM_FIELD_TYPE_SELECT_LIST
,
'
0
'
,
''
,
'
BLA;BLA-BLA
'
),
(
'
file
'
,
CUSTOM_FIELD_TYPE_FILE
,
'
bla.txt
'
,
'
bla.txt
'
),
])
def
test_initial_edit_with_custom_field
(
self
,
_
,
field_type
,
expected_initial_value
,
value
,
possible_values
=
''
):
field
=
CustomStudySubjectField
.
objects
.
create
(
study
=
get_test_study
(),
default_value
=
value
,
type
=
field_type
,
possible_values
=
possible_values
)
form
=
StudySubjectEditForm
(
instance
=
self
.
study_subject
)
self
.
assertTrue
(
form
[
get_study_subject_field_id
(
field
)].
initial
,
expected_initial_value
)
def
test_invalid_mpower_id_edit
(
self
):
self
.
study_subject
.
mpower_id
=
"
mpower_002
"
self
.
study_subject
.
nd_number
=
"
ND0002
"
...
...
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