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
4ac0768d
Commit
4ac0768d
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added tests and added 400 response if invalid request
parent
2007672d
No related branches found
No related tags found
1 merge request
!171
Feature/daily availability
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/tests/view/test_appointments.py
+37
-2
37 additions, 2 deletions
smash/web/tests/view/test_appointments.py
smash/web/views/appointment.py
+3
-0
3 additions, 0 deletions
smash/web/views/appointment.py
with
40 additions
and
2 deletions
smash/web/tests/view/test_appointments.py
+
37
−
2
View file @
4ac0768d
...
@@ -4,11 +4,11 @@ import logging
...
@@ -4,11 +4,11 @@ import logging
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.urls
import
reverse
from
django.urls
import
reverse
from
web.forms
import
SubjectEditForm
,
StudySubjectEditForm
,
AppointmentEditForm
from
web.forms
import
SubjectEditForm
,
StudySubjectEditForm
,
AppointmentEditForm
,
AppointmentAddForm
from
web.models
import
Appointment
,
StudySubject
,
Visit
from
web.models
import
Appointment
,
StudySubject
,
Visit
from
web.tests
import
LoggedInTestCase
from
web.tests
import
LoggedInTestCase
from
web.tests.functions
import
create_study_subject
,
create_visit
,
create_appointment
,
create_worker
,
\
from
web.tests.functions
import
create_study_subject
,
create_visit
,
create_appointment
,
create_worker
,
\
create_flying_team
,
format_form_field
create_flying_team
,
format_form_field
,
get_test_location
from
web.views.notifications
import
get_today_midnight_date
from
web.views.notifications
import
get_today_midnight_date
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -19,6 +19,41 @@ class AppointmentsViewTests(LoggedInTestCase):
...
@@ -19,6 +19,41 @@ class AppointmentsViewTests(LoggedInTestCase):
super
(
AppointmentsViewTests
,
self
).
setUp
()
super
(
AppointmentsViewTests
,
self
).
setUp
()
create_worker
(
self
.
user
,
True
)
create_worker
(
self
.
user
,
True
)
def
test_get_add_general_appointment
(
self
):
#test get without visit_id
response
=
self
.
client
.
get
(
reverse
(
'
web.views.appointment_add_general
'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_get_add_appointment
(
self
):
#test get with visit_id
subject
=
create_study_subject
()
visit
=
create_visit
(
subject
)
response
=
self
.
client
.
get
(
reverse
(
'
web.views.appointment_add
'
,
kwargs
=
{
'
visit_id
'
:
visit
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_post_add_general_appointment
(
self
):
location
=
get_test_location
()
form_appointment
=
AppointmentAddForm
(
user
=
self
.
user
)
form_data
=
{}
form_data
[
'
datetime_when
'
]
=
datetime
.
datetime
.
today
()
form_data
[
'
location
'
]
=
location
.
id
form_data
[
'
length
'
]
=
10
response
=
self
.
client
.
post
(
reverse
(
'
web.views.appointment_add_general
'
),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_add_appointment
(
self
):
subject
=
create_study_subject
()
visit
=
create_visit
(
subject
)
location
=
get_test_location
()
form_data
=
{}
form_appointment
=
AppointmentAddForm
(
user
=
self
.
user
)
form_data
[
'
datetime_when
'
]
=
datetime
.
datetime
.
today
()
form_data
[
'
location
'
]
=
location
.
id
form_data
[
'
length
'
]
=
10
response
=
self
.
client
.
post
(
reverse
(
'
web.views.appointment_add
'
,
kwargs
=
{
'
visit_id
'
:
visit
.
id
}),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_appointments_list_request
(
self
):
def
test_appointments_list_request
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'
web.views.appointments
'
))
response
=
self
.
client
.
get
(
reverse
(
'
web.views.appointments
'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/appointment.py
+
3
−
0
View file @
4ac0768d
...
@@ -56,6 +56,9 @@ def appointment_add(request, visit_id=None):
...
@@ -56,6 +56,9 @@ def appointment_add(request, visit_id=None):
return
redirect
(
'
web.views.appointments
'
)
return
redirect
(
'
web.views.appointments
'
)
else
:
else
:
return
redirect
(
'
web.views.visit_details
'
,
id
=
visit_id
)
return
redirect
(
'
web.views.visit_details
'
,
id
=
visit_id
)
else
:
raise
ValidationError
(
"
Invalid request: Errors: {}. Non field errors: {}
"
.
format
(
form
.
errors
,
form
.
non_field_errors
()))
else
:
else
:
form
=
AppointmentAddForm
(
user
=
request
.
user
)
form
=
AppointmentAddForm
(
user
=
request
.
user
)
...
...
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