Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Felix Blanke
AKPlanning
Commits
8d049baa
Commit
8d049baa
authored
3 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Make tests more descriptive
parent
61922712
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Refactor main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKModel/views/ak.py
+8
-4
8 additions, 4 deletions
AKModel/views/ak.py
with
8 additions
and
4 deletions
AKModel/views/ak.py
+
8
−
4
View file @
8d049baa
...
...
@@ -52,12 +52,15 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
def
_test_slot_contained
(
self
,
slot
:
Availability
,
availabilities
:
List
[
Availability
])
->
bool
:
"""
Test if slot is contained in any member of availabilities.
"""
return
any
(
availability
.
contains
(
slot
)
for
availability
in
availabilities
)
def
_test_event_covered
(
self
,
availabilities
:
List
[
Availability
])
->
bool
:
def
_test_event_not_covered
(
self
,
availabilities
:
List
[
Availability
])
->
bool
:
"""
Test if event is not covered by availabilities.
"""
return
not
Availability
.
is_event_covered
(
self
.
event
,
availabilities
)
def
_test_fixed_ak
(
self
,
ak_id
,
slot
:
Availability
,
ak_fixed
:
dict
)
->
bool
:
def
_test_ak_fixed_in_slot
(
self
,
ak_id
,
slot
:
Availability
,
ak_fixed
:
dict
)
->
bool
:
"""
Test if AK defined by `ak_id` is fixed to happen during slot.
"""
if
not
ak_id
in
ak_fixed
:
return
False
...
...
@@ -65,8 +68,9 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
return
fixed_slot
.
overlaps
(
slot
,
strict
=
True
)
def
_test_add_constraint
(
self
,
slot
:
Availability
,
availabilities
:
List
[
Availability
])
->
bool
:
"""
Test if object is not available for whole event and may happen during slot.
"""
return
(
self
.
_test_event_covered
(
availabilities
)
self
.
_test_event_
not_
covered
(
availabilities
)
and
self
.
_test_slot_contained
(
slot
,
availabilities
)
)
...
...
@@ -123,7 +127,7 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
for
ak_id
,
availabilities
in
ak_availabilities
.
items
()
if
(
self
.
_test_add_constraint
(
timeslot
.
avail
,
availabilities
)
or
self
.
_test_fixed_
ak
(
ak_id
,
timeslot
.
avail
,
ak_fixed
)
or
self
.
_test_
ak_
fixed_
in_slot
(
ak_id
,
timeslot
.
avail
,
ak_fixed
)
)
])
time_constraints
.
extend
([
...
...
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