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
0713094a
Commit
0713094a
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
subject view tests use new SubjectType
parent
af192ac1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!305
Resolve "Allow for adding modifying types of subjects"
Changes
2
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/view/test_subjects.py
+7
-6
7 additions, 6 deletions
smash/web/tests/view/test_subjects.py
with
8 additions
and
7 deletions
smash/web/forms/study_subject_forms.py
+
1
−
1
View file @
0713094a
...
...
@@ -187,7 +187,7 @@ class StudySubjectAddForm(StudySubjectForm):
else
:
subject_type
=
self
.
cleaned_data
.
get
(
'
type
'
,
None
)
if
subject_type
is
not
None
:
screening_number_prefix
=
SCREENING_NUMBER_PREFIXES_FOR_TYPE
[
subject_type
]
screening_number_prefix
=
subject_type
.
screening_number_prefix
if
screening_number_prefix
is
None
:
return
None
prefix_screening_number
=
screening_number_prefix
+
"
-
"
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_subjects.py
+
7
−
6
View file @
0713094a
...
...
@@ -13,7 +13,8 @@ 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
from
web.tests.functions
import
create_study_subject
,
create_visit
,
create_appointment
,
get_test_location
,
\
create_language
,
get_resource_path
,
get_test_study
,
format_form_field
create_language
,
get_resource_path
,
get_test_study
,
format_form_field
,
get_patient_subject_type
,
\
get_control_subject_type
from
web.views.notifications
import
get_today_midnight_date
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -202,7 +203,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
print
(
form
.
errors
)
self
.
assertTrue
(
form
.
is_valid
())
form_data
[
"
study_subject-type
"
]
=
SUBJECT_TYPE_CHOICES_CONTROL
form_data
[
"
study_subject-type
"
]
=
get_control_subject_type
().
id
response
=
self
.
client
.
post
(
reverse
(
'
web.views.subject_add
'
,
kwargs
=
{
'
study_id
'
:
self
.
study
.
id
}),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
...
...
@@ -221,7 +222,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
form_data
=
self
.
create_add_form_data_for_study_subject
()
form_data
[
"
study_subject-type
"
]
=
SUBJECT_TYPE_CHOICES_CONTROL
form_data
[
"
study_subject-type
"
]
=
get_control_subject_type
().
id
form_data
[
"
study_subject-referral_letter
"
]
=
SimpleUploadedFile
(
"
file.txt
"
,
b
"
file_content
"
)
form
=
SubjectAddForm
(
data
=
form_data
,
prefix
=
"
subject
"
)
...
...
@@ -252,7 +253,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
form_data
[
"
subject-first_name
"
]
=
"
John
"
form_data
[
"
subject-last_name
"
]
=
"
Doe
"
form_data
[
"
subject-sex
"
]
=
SEX_CHOICES_MALE
form_data
[
"
study_subject-type
"
]
=
SUBJECT_TYPE_CHOICES_PATIENT
form_data
[
"
study_subject-type
"
]
=
get_patient_subject_type
().
id
form_data
[
"
study_subject-subject
"
]
=
self
.
study_subject
.
id
form_data
[
"
study_subject-postponed
"
]
=
False
...
...
@@ -297,7 +298,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
self
.
worker
.
roles
.
all
()[
0
].
permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
"
add_subject
"
))
self
.
worker
.
save
()
form_data
=
self
.
create_add_form_data_for_study_subject
()
form_data
[
"
study_subject-type
"
]
=
SUBJECT_TYPE_CHOICES_CONTROL
form_data
[
"
study_subject-type
"
]
=
get_control_subject_type
().
id
form_data
[
"
subject-country
"
]
=
COUNTRY_OTHER_ID
response
=
self
.
client
.
post
(
reverse
(
'
web.views.subject_add
'
,
kwargs
=
{
'
study_id
'
:
self
.
study
.
id
}),
...
...
@@ -348,7 +349,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
form_data
=
self
.
create_edit_form_data_for_study_subject
(
self
.
study_subject
)
count
=
Provenance
.
objects
.
all
().
count
()
form_data
[
"
study_subject-type
"
]
=
SUBJECT_TYPE_CHOICES_PATIENT
form_data
[
"
study_subject-type
"
]
=
get_patient_subject_type
().
id
response
=
self
.
client
.
post
(
reverse
(
'
web.views.subject_edit
'
,
kwargs
=
{
'
id
'
:
self
.
study_subject
.
id
}),
data
=
form_data
)
...
...
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