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
277484d4
There was a problem fetching the pipeline metadata.
Commit
277484d4
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
unit test for appointments api
parent
3a9de20c
No related branches found
No related tags found
1 merge request
!35
performance on appointment list
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/test_api_appointment.py
+62
-3
62 additions, 3 deletions
smash/web/tests/test_api_appointment.py
with
62 additions
and
3 deletions
smash/web/tests/test_api_appointment.py
+
62
−
3
View file @
277484d4
# coding=utf-8
# coding=utf-8
import
datetime
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.test
import
Client
from
django.test
import
Client
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.urls
import
reverse
from
web.tests.functions
import
create_subject
,
create_worker
,
create_visit
,
create_appointment
from
web.tests.functions
import
create_subject
,
create_worker
,
create_visit
,
create_appointment
,
\
from
web.views.appointment
import
APPOINTMENT_LIST_GENERIC
create_appointment_type
,
create_get_suffix
from
web.views.appointment
import
APPOINTMENT_LIST_GENERIC
,
APPOINTMENT_LIST_APPROACHING
,
APPOINTMENT_LIST_UNFINISHED
from
web.views.notifications
import
get_today_midnight_date
class
TestApi
(
TestCase
):
class
TestApi
(
TestCase
):
...
@@ -30,8 +34,9 @@ class TestApi(TestCase):
...
@@ -30,8 +34,9 @@ class TestApi(TestCase):
self
.
subject
.
save
()
self
.
subject
.
save
()
visit
=
create_visit
(
self
.
subject
)
visit
=
create_visit
(
self
.
subject
)
create_appointment
(
visit
)
create_appointment
(
visit
)
appointment2
=
create_appointment
(
visit
)
appointment2
=
create_appointment
(
visit
,
get_today_midnight_date
()
)
appointment2
.
visit
=
None
appointment2
.
visit
=
None
appointment2
.
appointment_types
.
add
(
create_appointment_type
())
appointment2
.
save
()
appointment2
.
save
()
url
=
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_GENERIC
})
url
=
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_GENERIC
})
...
@@ -39,3 +44,57 @@ class TestApi(TestCase):
...
@@ -39,3 +44,57 @@ class TestApi(TestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
name
in
response
.
content
)
self
.
assertTrue
(
name
in
response
.
content
)
def
test_appointments_approaching
(
self
):
name
=
"
Piotrek
"
self
.
subject
.
first_name
=
name
self
.
subject
.
save
()
visit
=
create_visit
(
self
.
subject
)
create_appointment
(
visit
,
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=
2
))
url
=
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_APPROACHING
})
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
name
in
response
.
content
)
def
test_appointments_unfinished
(
self
):
name
=
"
Piotrek
"
self
.
subject
.
first_name
=
name
self
.
subject
.
save
()
visit
=
create_visit
(
self
.
subject
)
create_appointment
(
visit
,
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=-
12
))
url
=
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_UNFINISHED
})
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
name
in
response
.
content
)
def
test_get_calendar_appointments
(
self
):
name
=
"
Peter
"
self
.
subject
.
first_name
=
name
self
.
subject
.
save
()
visit
=
create_visit
(
self
.
subject
)
appointment
=
create_appointment
(
visit
,
get_today_midnight_date
())
appointment
.
appointment_types
.
add
(
create_appointment_type
())
appointment
.
save
()
params
=
{
"
start_date
"
:
(
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=
2
)).
strftime
(
"
%Y-%m-%d
"
),
"
end_date
"
:
(
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=
3
)).
strftime
(
"
%Y-%m-%d
"
),
}
url
=
(
"
%s
"
+
create_get_suffix
(
params
))
%
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_GENERIC
})
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
name
in
response
.
content
)
params
[
"
start_date
"
]
=
(
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=-
2
)).
strftime
(
"
%Y-%m-%d
"
)
url
=
(
"
%s
"
+
create_get_suffix
(
params
))
%
reverse
(
'
web.api.appointments
'
,
kwargs
=
{
'
type
'
:
APPOINTMENT_LIST_GENERIC
})
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
name
in
response
.
content
)
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