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
75da6d99
There was a problem fetching the pipeline mini graph.
Commit
75da6d99
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
unit test for filtering visit data
parent
9d1226f4
No related branches found
No related tags found
1 merge request
!107
Resolve "exceeded visits list & unfinished visits list"
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/api_views/test_visit.py
+97
-6
97 additions, 6 deletions
smash/web/tests/api_views/test_visit.py
with
97 additions
and
6 deletions
smash/web/tests/api_views/test_visit.py
+
97
−
6
View file @
75da6d99
...
@@ -6,12 +6,13 @@ import logging
...
@@ -6,12 +6,13 @@ import logging
from
django.urls
import
reverse
from
django.urls
import
reverse
from
web.api_views.visit
import
get_visits_filtered
,
get_visits_order
from
web.api_views.visit
import
get_visits_filtered
,
get_visits_order
from
web.models
import
Visit
from
web.models
import
Visit
,
AppointmentTypeLink
,
Appointment
from
web.models.study_visit_list
import
VISIT_LIST_GENERIC
,
VISIT_LIST_EXCEEDED_TIME
,
VISIT_LIST_UNFINISHED
,
\
from
web.models.study_visit_list
import
VISIT_LIST_GENERIC
,
VISIT_LIST_EXCEEDED_TIME
,
VISIT_LIST_UNFINISHED
,
\
VISIT_LIST_MISSING_APPOINTMENTS
,
VISIT_LIST_APPROACHING_WITHOUT_APPOINTMENTS
,
\
VISIT_LIST_MISSING_APPOINTMENTS
,
VISIT_LIST_APPROACHING_WITHOUT_APPOINTMENTS
,
\
VISIT_LIST_APPROACHING_FOR_MAIL_CONTACT
VISIT_LIST_APPROACHING_FOR_MAIL_CONTACT
from
web.tests
import
LoggedInWithWorkerTestCase
from
web.tests
import
LoggedInWithWorkerTestCase
from
web.tests.functions
import
create_study_subject
,
create_get_suffix
,
create_visit
from
web.tests.functions
import
create_study_subject
,
create_get_suffix
,
create_visit
,
create_appointment_type
,
\
create_flying_team
,
create_appointment
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__
)
...
@@ -42,6 +43,12 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
...
@@ -42,6 +43,12 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
response
=
self
.
client
.
get
(
reverse
(
'
web.api.visits
'
,
kwargs
=
{
'
visit_list_type
'
:
VISIT_LIST_EXCEEDED_TIME
}))
response
=
self
.
client
.
get
(
reverse
(
'
web.api.visits
'
,
kwargs
=
{
'
visit_list_type
'
:
VISIT_LIST_EXCEEDED_TIME
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_visits_generic
(
self
):
self
.
visit
.
appointment_types
.
add
(
create_appointment_type
())
self
.
visit
.
save
()
response
=
self
.
client
.
get
(
reverse
(
'
web.api.visits
'
,
kwargs
=
{
'
visit_list_type
'
:
VISIT_LIST_GENERIC
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_visits_unfinished
(
self
):
def
test_visits_unfinished
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'
web.api.visits
'
,
kwargs
=
{
'
visit_list_type
'
:
VISIT_LIST_UNFINISHED
}))
response
=
self
.
client
.
get
(
reverse
(
'
web.api.visits
'
,
kwargs
=
{
'
visit_list_type
'
:
VISIT_LIST_UNFINISHED
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
@@ -176,7 +183,91 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
...
@@ -176,7 +183,91 @@ class TestVisitApi(LoggedInWithWorkerTestCase):
# visit_number is adjusted automatically according to start date
# visit_number is adjusted automatically according to start date
self
.
check_visit_ordered
(
"
visit_number
"
,
[
visit1
,
visit2
])
self
.
check_visit_ordered
(
"
visit_number
"
,
[
visit1
,
visit2
])
def
test_subjects_filter_unknown
(
self
):
def
test_visits_sort_unknown
(
self
):
self
.
check_visit_ordered
([[
"
some_unknown
"
,
"
unknown data
"
]],
[
self
.
visit
])
self
.
check_visit_ordered
(
"
some_unknown
"
,
[
self
.
visit
])
self
.
check_visit_ordered
([[
""
,
""
]],
[
self
.
visit
])
self
.
check_visit_ordered
(
""
,
[
self
.
visit
])
self
.
check_visit_ordered
([[
""
,
None
]],
[
self
.
visit
])
self
.
check_visit_ordered
(
None
,
[
self
.
visit
])
def
test_visits_filter_last_name
(
self
):
subject
=
self
.
study_subject
subject
.
subject
.
last_name
=
"
XXX
"
subject
.
subject
.
save
()
self
.
check_visit_filtered
([[
"
last_name
"
,
"
Q
"
]],
[])
self
.
check_visit_filtered
([[
"
last_name
"
,
"
xx
"
]],
[
self
.
visit
])
def
test_visits_filter_flying_team
(
self
):
subject
=
self
.
study_subject
subject
.
flying_team
=
create_flying_team
()
subject
.
save
()
self
.
check_visit_filtered
([[
"
flying_team
"
,
"
-1
"
]],
[])
self
.
check_visit_filtered
([[
"
flying_team
"
,
str
(
subject
.
flying_team
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_default_location
(
self
):
self
.
check_visit_filtered
([[
"
default_location
"
,
"
-1
"
]],
[])
self
.
check_visit_filtered
([[
"
default_location
"
,
str
(
self
.
study_subject
.
default_location
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_is_finished
(
self
):
self
.
check_visit_filtered
([[
"
is_finished
"
,
str
(
not
self
.
visit
.
is_finished
).
lower
()]],
[])
self
.
check_visit_filtered
([[
"
is_finished
"
,
str
(
self
.
visit
.
is_finished
).
lower
()]],
[
self
.
visit
])
def
test_visits_filter_post_mail_sent
(
self
):
self
.
check_visit_filtered
([[
"
post_mail_sent
"
,
str
(
not
self
.
visit
.
post_mail_sent
).
lower
()]],
[])
self
.
check_visit_filtered
([[
"
post_mail_sent
"
,
str
(
self
.
visit
.
post_mail_sent
).
lower
()]],
[
self
.
visit
])
def
test_visits_filter_visit_number
(
self
):
self
.
check_visit_filtered
([[
"
visit_number
"
,
"
-1
"
]],
[])
self
.
check_visit_filtered
([[
"
visit_number
"
,
str
(
self
.
visit
.
visit_number
)]],
[
self
.
visit
])
def
test_visits_filter_visible_appointment_types
(
self
):
appointment_type_1
=
create_appointment_type
()
appointment_type_2
=
create_appointment_type
()
self
.
visit
.
appointment_types
.
add
(
appointment_type_1
)
self
.
visit
.
save
()
self
.
check_visit_filtered
([[
"
visible_appointment_types
"
,
str
(
appointment_type_2
.
id
)]],
[])
self
.
check_visit_filtered
([[
"
visible_appointment_types
"
,
str
(
appointment_type_1
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_visible_appointment_types_missing
(
self
):
appointment_type_1
=
create_appointment_type
()
appointment_type_2
=
create_appointment_type
()
self
.
visit
.
appointment_types
.
add
(
appointment_type_1
)
self
.
visit
.
save
()
appointment
=
create_appointment
(
self
.
visit
)
AppointmentTypeLink
.
objects
.
create
(
appointment
=
appointment
,
appointment_type
=
appointment_type_2
)
self
.
check_visit_filtered
([[
"
visible_appointment_types_missing
"
,
str
(
appointment_type_2
.
id
)]],
[])
self
.
check_visit_filtered
([[
"
visible_appointment_types_missing
"
,
str
(
appointment_type_1
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_visible_appointment_types_done
(
self
):
appointment_type_1
=
create_appointment_type
()
appointment_type_2
=
create_appointment_type
()
self
.
visit
.
appointment_types
.
add
(
appointment_type_1
)
self
.
visit
.
save
()
appointment
=
create_appointment
(
self
.
visit
)
appointment
.
status
=
Appointment
.
APPOINTMENT_STATUS_FINISHED
appointment
.
save
()
AppointmentTypeLink
.
objects
.
create
(
appointment
=
appointment
,
appointment_type
=
appointment_type_1
)
self
.
check_visit_filtered
([[
"
visible_appointment_types_done
"
,
str
(
appointment_type_2
.
id
)]],
[])
self
.
check_visit_filtered
([[
"
visible_appointment_types_done
"
,
str
(
appointment_type_1
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_visible_appointment_types_in_progress
(
self
):
appointment_type_1
=
create_appointment_type
()
appointment_type_2
=
create_appointment_type
()
self
.
visit
.
appointment_types
.
add
(
appointment_type_1
)
self
.
visit
.
save
()
appointment
=
create_appointment
(
self
.
visit
)
AppointmentTypeLink
.
objects
.
create
(
appointment
=
appointment
,
appointment_type
=
appointment_type_1
)
self
.
check_visit_filtered
([[
"
visible_appointment_types_in_progress
"
,
str
(
appointment_type_2
.
id
)]],
[])
self
.
check_visit_filtered
([[
"
visible_appointment_types_in_progress
"
,
str
(
appointment_type_1
.
id
)]],
[
self
.
visit
])
def
test_visits_filter_unknown
(
self
):
self
.
check_visit_filtered
([[
"
some_unknown
"
,
"
unknown data
"
]],
[
self
.
visit
])
self
.
check_visit_filtered
([[
""
,
""
]],
[
self
.
visit
])
self
.
check_visit_filtered
([[
None
,
None
]],
[
self
.
visit
])
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