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
7a5cf981
Commit
7a5cf981
authored
3 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
organized imports, indentation
parent
fddee87a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!336
Pylint checks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/view/test_visit.py
+12
-7
12 additions, 7 deletions
smash/web/tests/view/test_visit.py
with
12 additions
and
7 deletions
smash/web/tests/view/test_visit.py
+
12
−
7
View file @
7a5cf981
import
datetime
import
datetime
import
logging
import
logging
from
django.contrib.messages
import
get_messages
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -11,7 +12,6 @@ from web.tests import LoggedInTestCase
...
@@ -11,7 +12,6 @@ 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
,
format_form_field
create_language
,
get_resource_path
,
format_form_field
from
web.views.notifications
import
get_today_midnight_date
from
web.views.notifications
import
get_today_midnight_date
from
django.contrib.messages
import
get_messages
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -27,8 +27,10 @@ class VisitViewTests(LoggedInTestCase):
...
@@ -27,8 +27,10 @@ class VisitViewTests(LoggedInTestCase):
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_details
'
,
kwargs
=
{
'
id
'
:
visit
.
id
}))
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_details
'
,
kwargs
=
{
'
id
'
:
visit
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
visit
.
subject
.
comments
.
encode
(
'
utf8
'
)
in
response
.
content
,
msg
=
"
No study subject data in rendered response
"
)
self
.
assertTrue
(
visit
.
subject
.
comments
.
encode
(
'
utf8
'
)
in
response
.
content
,
self
.
assertTrue
(
visit
.
subject
.
subject
.
address
.
encode
(
'
utf8
'
)
in
response
.
content
,
msg
=
"
No subject data in rendered response
"
)
msg
=
"
No study subject data in rendered response
"
)
self
.
assertTrue
(
visit
.
subject
.
subject
.
address
.
encode
(
'
utf8
'
)
in
response
.
content
,
msg
=
"
No subject data in rendered response
"
)
def
test_save_visit_details
(
self
):
def
test_save_visit_details
(
self
):
visit
=
create_visit
()
visit
=
create_visit
()
...
@@ -122,11 +124,12 @@ class VisitViewTests(LoggedInTestCase):
...
@@ -122,11 +124,12 @@ class VisitViewTests(LoggedInTestCase):
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_unfinish
'
,
args
=
[
visit
.
id
]),
follow
=
True
)
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_unfinish
'
,
args
=
[
visit
.
id
]),
follow
=
True
)
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertEqual
(
str
(
messages
[
0
]),
'
You are not authorized to view this page or perform this action. Request permissions to the system administrator.
'
)
self
.
assertEqual
(
str
(
messages
[
0
]),
'
You are not authorized to view this page or perform this action.
'
'
Request permissions to the system administrator.
'
)
new_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
new_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
self
.
assertEqual
(
2
,
Visit
.
objects
.
count
())
self
.
assertEqual
(
2
,
Visit
.
objects
.
count
())
self
.
assertTrue
(
new_visit
.
is_finished
)
self
.
assertTrue
(
new_visit
.
is_finished
)
def
test_unfinish_visit_with_future_visit_without_appointments
(
self
):
def
test_unfinish_visit_with_future_visit_without_appointments
(
self
):
self
.
login_as_admin
()
self
.
login_as_admin
()
visit
=
create_visit
()
visit
=
create_visit
()
...
@@ -180,7 +183,7 @@ class VisitViewTests(LoggedInTestCase):
...
@@ -180,7 +183,7 @@ class VisitViewTests(LoggedInTestCase):
new_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
new_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
self
.
assertTrue
(
new_visit
.
is_finished
)
self
.
assertTrue
(
new_visit
.
is_finished
)
self
.
assertEqual
(
2
,
Visit
.
objects
.
count
())
self
.
assertEqual
(
2
,
Visit
.
objects
.
count
())
next_visit
=
new_visit
.
next_visit
next_visit
=
new_visit
.
next_visit
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_mark
'
,
args
=
[
next_visit
.
id
,
"
finished
"
]))
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_mark
'
,
args
=
[
next_visit
.
id
,
"
finished
"
]))
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
...
@@ -192,7 +195,9 @@ class VisitViewTests(LoggedInTestCase):
...
@@ -192,7 +195,9 @@ class VisitViewTests(LoggedInTestCase):
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_unfinish
'
,
args
=
[
visit
.
id
]),
follow
=
True
)
response
=
self
.
client
.
get
(
reverse
(
'
web.views.visit_unfinish
'
,
args
=
[
visit
.
id
]),
follow
=
True
)
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertEqual
(
str
(
messages
[
0
]),
"
Visit can
'
t be unfinished. Only visits with one inmediate future visit (without appointments) can be unfinished.
"
)
self
.
assertEqual
(
str
(
messages
[
0
]),
"
Visit can
'
t be unfinished.
"
"
Only visits with one inmediate future visit
"
"
(without appointments) can be unfinished.
"
)
self
.
assertEqual
(
3
,
Visit
.
objects
.
count
())
self
.
assertEqual
(
3
,
Visit
.
objects
.
count
())
original_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
original_visit
=
Visit
.
objects
.
get
(
id
=
visit
.
id
)
self
.
assertTrue
(
original_visit
.
is_finished
)
self
.
assertTrue
(
original_visit
.
is_finished
)
...
...
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