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
7b81782d
Commit
7b81782d
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
unit test for checking if mail template info is rendered on visit page
parent
9c37f56e
No related branches found
No related tags found
1 merge request
!100
Test coverage unit tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/tests/view/test_visit.py
+30
-6
30 additions, 6 deletions
smash/web/tests/view/test_visit.py
smash/web/views/visit.py
+4
-0
4 additions, 0 deletions
smash/web/views/visit.py
with
34 additions
and
6 deletions
smash/web/tests/view/test_visit.py
+
30
−
6
View file @
7b81782d
...
...
@@ -4,9 +4,11 @@ import logging
from
django.urls
import
reverse
from
web.forms
import
VisitDetailForm
,
VisitAddForm
from
web.models
import
Visit
from
web.models
import
Visit
,
MailTemplate
from
web.models.constants
import
MAIL_TEMPLATE_CONTEXT_VISIT
from
web.tests
import
LoggedInTestCase
from
web.tests.functions
import
create_study_subject
,
create_visit
,
create_appointment
,
create_appointment_type
from
web.tests.functions
import
create_study_subject
,
create_visit
,
create_appointment
,
create_appointment_type
,
\
create_language
,
get_resource_path
from
web.views.notifications
import
get_today_midnight_date
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -30,19 +32,41 @@ class VisitViewTests(LoggedInTestCase):
visit
=
create_visit
()
create_appointment
(
visit
)
form_appointment
=
VisitDetailForm
(
instance
=
visit
)
form_data
=
self
.
create_visit_detail_form_data
(
visit
)
response
=
self
.
client
.
post
(
reverse
(
'
web.views.visit_details
'
,
kwargs
=
{
'
id
'
:
visit
.
id
}),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertNotContains
(
response
,
"
error
"
)
@staticmethod
def
create_visit_detail_form_data
(
visit
):
visit_detail_form
=
VisitDetailForm
(
instance
=
visit
)
form_data
=
{}
for
key
,
value
in
form_appointment
.
initial
.
items
():
for
key
,
value
in
visit_detail_form
.
initial
.
items
():
if
value
is
not
None
:
if
isinstance
(
value
,
datetime
.
datetime
):
form_data
[
key
]
=
value
.
strftime
(
"
%Y-%m-%d
"
)
else
:
form_data
[
key
]
=
value
return
form_data
def
test_render_visit_details_with_mail_templates
(
self
):
language
=
create_language
(
name
=
"
German
"
)
template_name
=
"
german_template
"
template_file
=
get_resource_path
(
'
upcoming_appointment_FR.docx
'
)
visit
=
create_visit
()
visit
.
subject
.
subject
.
default_written_communication_language
=
language
visit
.
subject
.
subject
.
save
()
MailTemplate
(
name
=
template_name
,
language
=
language
,
context
=
MAIL_TEMPLATE_CONTEXT_VISIT
,
template_file
=
template_file
).
save
()
form_data
=
self
.
create_visit_detail_form_data
(
visit
)
response
=
self
.
client
.
post
(
reverse
(
'
web.views.visit_details
'
,
kwargs
=
{
'
id
'
:
visit
.
id
}),
data
=
form_data
)
response
=
self
.
client
.
post
(
reverse
(
'
web.views.visit_details
'
,
kwargs
=
{
'
id
'
:
visit
.
id
}),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertNotContains
(
response
,
"
error
"
)
self
.
assertTrue
(
template_name
in
response
.
content
)
def
test_render_add_visit
(
self
):
study_subject
=
create_study_subject
()
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/visit.py
+
4
−
0
View file @
7b81782d
# coding=utf-8
import
logging
from
django.shortcuts
import
get_object_or_404
,
redirect
from
notifications
import
get_active_visits_with_missing_appointments
,
get_unfinished_visits
,
\
...
...
@@ -8,6 +10,8 @@ from . import wrap_response
from
..forms
import
VisitDetailForm
,
StudySubjectDetailForm
,
VisitAddForm
,
SubjectDetailForm
from
..models
import
Visit
,
Appointment
,
StudySubject
,
MailTemplate
logger
=
logging
.
getLogger
(
__name__
)
def
visits
(
request
):
visit_list
=
Visit
.
objects
.
order_by
(
'
-datetime_begin
'
)
...
...
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