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
4f1d4c2e
Commit
4f1d4c2e
authored
8 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
add visit tests added
parent
017f45a6
No related branches found
No related tags found
1 merge request
!31
Tests added
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/test_view_visit.py
+39
-5
39 additions, 5 deletions
smash/web/tests/test_view_visit.py
with
39 additions
and
5 deletions
smash/web/tests/test_view_visit.py
+
39
−
5
View file @
4f1d4c2e
...
...
@@ -4,11 +4,15 @@ from django.test import Client
from
django.test
import
TestCase
from
django.urls
import
reverse
from
functions
import
create_visit
,
create_appointment
,
create_user
,
create_appointment_type
from
functions
import
\
create_appointment
,
\
create_appointment_type
,
\
create_subject
,
\
create_visit
,
\
create_user
from
web.forms
import
VisitDetailForm
,
VisitAddForm
from
web.models
import
Subject
,
Visit
from
web.views.notifications
import
get_today_midnight_date
from
web.forms
import
VisitDetailForm
from
web.models
import
Visit
class
VisitViewTests
(
TestCase
):
...
...
@@ -45,6 +49,37 @@ class VisitViewTests(TestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
"
error
"
in
response
.
content
)
def
test_render_add_visit
(
self
):
subject
=
create_subject
()
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_add
'
,
kwargs
=
{
'
subject_id
'
:
subject
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_save_add_visit
(
self
):
visit_count
=
Visit
.
objects
.
all
().
count
()
subject
=
create_subject
()
form
=
VisitAddForm
()
form_data
=
{}
for
key
,
value
in
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
form_data
[
"
datetime_begin
"
]
=
"
2017-01-01
"
form_data
[
"
datetime_end
"
]
=
"
2017-04-01
"
form_data
[
"
subject
"
]
=
subject
.
id
response
=
self
.
client
.
post
(
reverse
(
'
web.views.visit_add
'
,
kwargs
=
{
'
subject_id
'
:
subject
.
id
}),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertFalse
(
"
error
"
in
response
.
content
)
visit_count_new
=
Visit
.
objects
.
all
().
count
()
self
.
assertEqual
(
visit_count
+
1
,
visit_count_new
)
def
test_mark_as_finished
(
self
):
visit
=
create_visit
()
...
...
@@ -101,4 +136,3 @@ class VisitViewTests(TestCase):
response
=
self
.
client
.
get
(
reverse
(
"
web.views.unfinished_visits
"
))
self
.
assertEqual
(
response
.
status_code
,
200
)
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