Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
RadioObservatory
LOFAR
Commits
34b805d5
Commit
34b805d5
authored
Mar 03, 2021
by
Roy de Goei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TMSS-475
Correct testcases for can_run_within_not_between_constraints
parent
bc90ec47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
45 deletions
+71
-45
SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
.../backend/services/scheduling/test/t_dynamic_scheduling.py
+71
-45
No files found.
SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
View file @
34b805d5
...
...
@@ -932,65 +932,91 @@ class TestTimeConstraints(TestCase):
self
.
assertTrue
(
tc1
.
can_run_anywhere_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
13
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
15
,
0
,
0
)))
def
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
(
self
):
"""
Just a simple wrapper to call 'can_run_anywhere_within_timewindow_with_time_constraints' function
with a 24 hours boundary 2020-01-01 12:00 - 2020-01-02 12:00
"""
return
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
def
test_can_run_within_between_constraints
(
self
):
"""
Test multiple 'between' and check overall result of can_run_within_timewindow_with_time_constraints
Test multiple 'between' constraints within 24 boundary and check overall result of
'can_run_within_timewindow_with_time_constraints'
This function will iterate between the boundary with boundary shift of 1hr and boundary length of
the observation duration, which is in this testcase two hour
i.e. 12-14, 13-15, 14-16,..etc.., 9-11
"""
# no constraints defined so should be OK
self
.
assertTrue
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
# not inside constraints of 1hr
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
11
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
))
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
13
,
0
,
0
))
# not inside constraints of 2hr
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraints of 1hr, we still 'can_run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
13
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
14
,
0
,
0
))
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
16
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
17
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraints of 2hr, we still 'can_run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
2
,
11
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
13
,
0
,
0
))
# inside constraint of 20hr 'too long' constraint
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
14
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
10
,
0
,
0
))
self
.
assertFalse
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraint of 24hr constraint, we still 'can_run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraint of 2hr, to fill the 'last gap', we 'can run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
2
,
10
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Clear all between constraints
self
.
scheduling_unit_blueprint
.
draft
.
scheduling_constraints_doc
[
'time'
][
"between"
]
=
[]
# Add constraints 'outside' the 24hr, now we 'can not run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
2
,
13
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
14
,
0
,
0
))
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
2
,
16
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
17
,
0
,
0
))
self
.
assertFalse
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraint 'outside' the 24hr, we 'still can not run'
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
9
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
))
self
.
assertFalse
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# add one 'inside' constraint, 1 hour within block of 2 hour so overall must be ok
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
13
,
30
,
0
),
datetime
(
2020
,
1
,
1
,
14
,
30
,
0
))
self
.
assertTrue
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
# not inside constraints of 3hr
self
.
add_time_between_constraint
(
datetime
(
2020
,
1
,
1
,
11
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
))
# should still be OK
self
.
assertTrue
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
def
test_can_run_within_not_between_constraints
(
self
):
"""
Test multiple 'not_between' and check overall result of can_run_within_timewindow_with_time_constraints
Test multiple 'not_between' constraints within 24 boundary and check overall result of
'can_run_within_timewindow_with_time_constraints'
This function will iterate between the boundary with boundary shift of 1hr and boundary length of
the observation duration, which is in this testcase two hour
i.e. 12-14, 13-15, 14-16,..etc.., 9-11
"""
# no constraints defined so should be OK
self
.
assertTrue
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
# not inside constraints of 1hr
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
11
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
))
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
13
,
0
,
0
))
# not inside constraints of 2hr
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
2
,
11
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
13
,
0
,
0
))
# inside constraint of 20hr 'too long' constraint
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
14
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
10
,
0
,
0
))
self
.
assertFalse
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
# add one 'outside' constraint, 1 hour which is still not ok
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
9
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
10
,
0
,
0
))
print
(
self
.
scheduling_unit_blueprint
.
draft
.
scheduling_constraints_doc
[
'time'
][
"not_between"
])
self
.
assertFalse
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraints of 1hr, we still 'can_run'
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
13
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
14
,
0
,
0
))
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
16
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
17
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraints of 2hr, we still 'can_run'
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
18
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
20
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraint of 20hr constraint, we still 'can_run'
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
8
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Add constraint of 2hr, to fill the 'last gap', now we can not run
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
2
,
10
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
))
self
.
assertFalse
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
# Clear all not_between constraints
self
.
scheduling_unit_blueprint
.
draft
.
scheduling_constraints_doc
[
'time'
][
"not_between"
]
=
[]
# not inside constraints of 1hr again
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
9
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
10
,
0
,
0
))
# should be OK now
self
.
assertTrue
(
tc1
.
can_run_within_timewindow_with_time_constraints
(
self
.
scheduling_unit_blueprint
,
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
2
,
12
,
0
,
0
)))
# Add one inside constraint and we are back not ok again
# TODO RGoe: Have to check why next is not working before finishing TMSS-475 !!!!!!!!!!
#self.add_time_not_between_constraint(datetime(2020, 1, 1, 13, 0, 0), datetime(2020, 1, 1, 14, 0, 0))
#self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint,
# datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0)))
# Add 4 hr constraints within 24 hours boundary, we can run
self
.
add_time_not_between_constraint
(
datetime
(
2020
,
1
,
1
,
12
,
0
,
0
),
datetime
(
2020
,
1
,
1
,
16
,
0
,
0
))
self
.
assertTrue
(
self
.
execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary
())
class
TestReservedStations
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment